How to send the form only once

msweb 19 Feb, 2013
Hello!
There is a form in the form of a questionnaire. How to do so, to fill in the questionnaire could only registered user and each registered user can fill out the application only one time?
joomla1.5.26, Chronoforms_V4_RC3.5.1
GreyHead 19 Feb, 2013
Hi msweb,

You can use the Authenticator action to restrict the form to registered users.

Save the User ID with the form results in the database, the ChronoForms DB Save action will do this for you.

When the form loads check the saved records to see if the current User ID is already recorded. If it is then don't show the form.

Bob
hubneraf 04 Oct, 2013
can you explain this please?
GreyHead 05 Oct, 2013
Hi Hubneraf,

There are various ways to do it depending on what you want to happen. The simplest is to add a Custom Code action and add the code to it to query the database table and redirect the user with a message if a record is found.

Bob
hubneraf 05 Oct, 2013
i undestand it
my problem is that i don't undestant how insert che custom code... and what sort of code i have to write
can you write an example please?πŸ™‚
thanks
GreyHead 06 Oct, 2013
Hi hubernaf,

Do you have the form data saving to a Database table now? If not, please see this FAQ.

Bob
hubneraf 07 Oct, 2013
yes, i have it
i need the custom code to do the control idπŸ™‚
πŸ˜€
GreyHead 07 Oct, 2013
Hi hubernaf,

What have you tried so far?

What is the name of the database table and what column do you need to check?

Bob
hubneraf 08 Oct, 2013
thanks bob

my db tagle is karmg_chronoforms_data_prova6 and i want to check for user id so, cf_user_id

thanks
GreyHead 10 Oct, 2013
Hi hubneraf,

You can use an Event Switcher [GH] action and the code will be something like:
<?php
$user =& JFactory::getUser();
$db =& JFactory::getDBO();
$query = "
    SELECT COUNT(*)
        FROM `#__chronoforms_data_prova6`
        WHERE `cf_user_id` = '{$user->id}' ;
";
$db->setQuery($query);
$count = $db->loadResult();
if ( $count >= 1 ) {
  // the form has already been completed
  return 'event_a';
}
?>

Bob
hubneraf 10 Oct, 2013
thanks so much bob
worksπŸ˜‰
This topic is locked and no more replies can be posted.