How to allow a user to upload and view/edit his own forms

terrytubby 20 Dec, 2010
Hi,

Chronoforms and ChronoConnectivity are both great! However I am pulling my hair now because I need a registered user to fill up his own form and later edit and update his results. Currently, all registered users can see the uploaded survey forms.

Here's what I did.

I created a survey form with chronoforms for a registered user. The form is great because it captures this user with his unique ID no. So no problems here.

I then proceed to use choronoconnectivity to display the results. Problem starts when User A can view all records from all users. The right way should be showing only User A's survey results.

Please help. I've searched all over the forum but am lost.

Cheers,
Terence
GreyHead 20 Dec, 2010
Hi Terence,

If you only want to display a single result then you don't need to use ChronoConnectivity (it's for showing a list of results). Instead use the Profile-page plug-in to show the single result for this user (either to display or edit).

Bob

PS There is a long worked example of user-linked editable data in the How-To document that you can buy here.
terrytubby 21 Dec, 2010
Hi Bob,

Thanks for the quick reply! I actually need to show a list of results.

Let me explain more on what I am doing. A user will be taking a list of survey forms everyday. After taking each survey form, he can view/edit his survey forms as and when he likes. So it's showing multiple lists of results.

Can I still use the profile plugin in this case?

Cheers!
Terence
GreyHead 21 Dec, 2010
Hi Terence,

OK - if it's a list then ChronoConnectivity is the better approach. But add a line in the WHERE filter box to select only the results that match the current user ID.

And best to add a check in the Edit form too.

Bob
terrytubby 22 Dec, 2010
Hi Bob,

I got to the WHERE sql part. But what statment should I add to extract the current user? Currently, the survey forms are showing to ALL registered users.

I used this:
,jos_users WHERE jos_chronoforms_invoiceSubmission.cf_user_id = jos_users.id

I tried to do a join statement, but no use.

Thanks,
Terence
GreyHead 22 Dec, 2010
Hi Terence,

You can use the Joomla! User Object to get the current user id. The most basic form of the code for the WHERE box is this
<?php
$user =& JFactory::getUser();
echo "WHERE `cf_user_id` = ".$user->id;
?>
You may need to elaborate it to add validation and other search parameters.

ChronoConnectivity doesn't support JOIN unfortunately but you don't need it here.

Bob

Later: fixed typo - a stray space in `cf_user_id `
terrytubby 23 Dec, 2010
Hi Bob,

I am really getting excited now....your code enables to find out the user ID. However, it's giving me this error:

Unknown column 'cf_user_id ' in 'where clause' SQL=SELECT count(*) FROM jos_chronoforms_invoiceSubmission WHERE `cf_user_id ` = 64

It seems I cannot just paste your code into the WHERE box just like that. Is there something else I need to do?

Thanks,
Terence
terrytubby 23 Dec, 2010
Hi Bob,

Silly me, just found out that there is an extra space in the `cf_user_id `. Once I've removed the space... IT WORKS LIKE A CHARM!!!!

Thanks for all your help!🙂
GreyHead 23 Dec, 2010
Hi Terence,

Apologies for the typo - well done for finding it.

I fixed my original post.

Bob
This topic is locked and no more replies can be posted.