Unfortunately, the username and password you have entered do not match!

Registration

Unfortunately, this username is already taken!

Unfortunately, this e-mail address is already used!

Please retype the verification code.

All fields are required

Setup form so each user can only submit once ?

Welcome, Guest
Username Password: Remember me

Setup form so each user can only submit once ?
(1 viewing) (1) Guest
  • Page:
  • 1

TOPIC: Setup form so each user can only submit once ?

Setup form so each user can only submit once ? 2 years, 2 months ago #9162

I'm sorry if this is dumb question as I am new to RSForms (Pro).

Is it possible to setup a form so that each user can only make 1 submission ?

I want to use RSForms for a Survey so therefore everyone should only provide 1 set of answers.

Help Appreciated .....

Re:Setup form so each user can only submit once ? 2 years, 2 months ago #9165

  • bogdanc
  • OFFLINE
  • Moderator
  • Posts: 629
Hello,

In order to stop the same user from submitting the form more than once you will have to paste this script in the "Scripts called on form display" area:

$rsuser =&JFactory::getUser();
$myid = intval($rsuser->get('id'));
if ($myid > 0 && mysql_num_rows(mysql_query("SELECT `SubmissionId` FROM `jos_RSFORM_SUBMISSIONS` WHERE `UserId`='".$myid."' AND `FormId`='1' LIMIT 1")) > 0)
$formLayout = 'You have already completed this form.';


Note that in the script you will have to change the FormId value to the id of the form that you use.
Last Edit: 2 years, 2 months ago by bogdanc.

Re:Setup form so each user can only submit once ? 1 year, 11 months ago #9951

Is there a way to pull this off without needing to be a user? Say, by IP?

I have a simple survey form that is available to all guests, but only want them to fill it out once.

Re:Setup form so each user can only submit once ? 1 year, 11 months ago #10001

  • patrick.jackson2
  • OFFLINE
  • Fresh Boarder
  • KPS - Joomla Consultant Melbourne Australia
  • Posts: 9
andrew.norris wrote:
Is there a way to pull this off without needing to be a user? Say, by IP?

I have a simple survey form that is available to all guests, but only want them to fill it out once.


Have a similar issue at the moment with a form needing to be restricted for a competition for one entry per email address.

Will post code when I figure it out, unless you worked yours out already and care to share?

Re:Setup form so each user can only submit once ? 1 year, 11 months ago #10047

  • bogdanc
  • OFFLINE
  • Moderator
  • Posts: 629
Hello,

If you wish to limit the user submission depending on the user's IP address then you can try placing a script similar to this one in the "Scripts called on form display" area:

$rsip =$_SERVER['REMOTE_ADDR'];
if (mysql_num_rows(mysql_query("SELECT `SubmissionId` FROM `jos_RSFORM_SUBMISSION_VALUES` WHERE `FieldValue`='".$rsip."' AND `FormId`='56' LIMIT 1")) > 0)
$formLayout = 'You have already completed this form.';


Also if you wish to prevent the same email address from submitting the form twice then you can try using a script similar to this one in the "Scripts called on form process" area:

$rsemail = $_POST['form']['email'];
$foundValid = false;
if (mysql_num_rows(mysql_query("SELECT `SubmissionId` FROM `jos_RSFORM_SUBMISSION_VALUES` WHERE `FieldValue`='".$rsemail."' AND `FormId`='56' LIMIT 1")) > 0)
$foundValid = true;
if($foundValid)
{
$invalid[]=RSresolveComponentName('email',$formId);
echo RSshowForm($formId, $_POST['form'], $invalid);
}


Note that in the script you will have to change the FormId value to the id of the form that you use and also the field "email" to the field which captures the user's email in your form.
Last Edit: 1 year, 10 months ago by bogdanc.

Re:Setup form so each user can only submit once ? 1 year, 7 months ago #10737

I'm trying to use the code that will prevent an email address from submitting a form multiple times.

 
 
$rsemail = $_POST['form']['email'];
$foundValid = false;
if (mysql_num_rows(mysql_query("SELECT `SubmissionId` FROM `jos_RSFORM_SUBMISSION_VALUES` WHERE `FieldValue`='".$rsemail."' AND `FormId`='4' LIMIT 1")) > 0)
$foundValid = true;
if($foundValid)
{
$invalid[]=RSresolveComponentName('email',$formId);
echo RSshowForm($formId, $_POST['form'], $invalid);
}


I put the code in place and changed the FormId, but it's not working. I'm using RS Form Pro 1.2.0. And the Joomla 1.5.18.

Any suggestions?
Last Edit: 1 year, 7 months ago by brian.woolard. Reason: code update

Re:Setup form so each user can only submit once ? 1 year, 7 months ago #10879

  • shweew
  • OFFLINE
  • Fresh Boarder
  • Posts: 1
brian.woolard wrote:
I'm trying to use the code that will prevent an email address from submitting a form multiple times.

 
 
$rsemail = $_POST['form']['email'];
$foundValid = false;
if (mysql_num_rows(mysql_query("SELECT `SubmissionId` FROM `jos_RSFORM_SUBMISSION_VALUES` WHERE `FieldValue`='".$rsemail."' AND `FormId`='4' LIMIT 1")) > 0)
$foundValid = true;
if($foundValid)
{
$invalid[]=RSresolveComponentName('email',$formId);
echo RSshowForm($formId, $_POST['form'], $invalid);
}


I put the code in place and changed the FormId, but it's not working. I'm using RS Form Pro 1.2.0. And the Joomla 1.5.18.

Any suggestions?


It is strange, why the code does not work for me?
I too use RS Form Pro 1.2.0. And the Joomla 1.5.18.
Help to troubleshoot.
Last Edit: 1 year, 7 months ago by shweew.

Re:Setup form so each user can only submit once ? 1 year, 7 months ago #10897

  • andreic
  • OFFLINE
  • Moderator
  • Posts: 494
Hello,

Instead of using a custom script in order to validate a unique value please try going to components/com_rsform/controller, edit the validation.php file and add the following function after the already existing ones:

function unique($param, $extra=null)
{
if (!email($param,null))
return false;
 
$db = JFactory::getDBO();
$param = $db->getEscaped($param);
$db->setQuery("SELECT * FROM #__rsform_submission_values WHERE `FieldName`='Email' AND `FieldValue`='".$param."'");
$db->query();
$invalid = $db->getNumRows();
if ($invalid)
return false;
return true;
}


This will create a new validation rule for all your forms. In order to apply it you just have to edit your fields and select "unique" for the "Validation rule".
Please note: my help is not official customer support. To receive your support, submit a ticket by clicking here
Regards,
RSJoomla! Development Team

Re:Setup form so each user can only submit once ? 1 year, 3 months ago #11806

I have just added this code to my site to prevent users from submitting the form more than once and i get the following error

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/xxxxxx/public_html/administrator/components/com_rsform/helpers/rsform.php(1043) : eval()'d code on line 3

Any help sorting this out will be usefull

Re:Setup form so each user can only submit once ? 1 year, 2 months ago #11976

As ashley.barnard said, I am also getting the following error:

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home3/xxxx/public_html/xxxxx/administrator/components/com_rsform/helpers/rsform.php(1099) : eval()'d code on line 4

Please help

Re:Setup form so each user can only submit once ? 1 year ago #12457

  • patrick.jackson2
  • OFFLINE
  • Fresh Boarder
  • KPS - Joomla Consultant Melbourne Australia
  • Posts: 9
Restrict by IP address

An update to bogdanc's code that works with RSForms 1.3.0 and above.

 
// Determine the IP address for the user
$rsip =$_SERVER['REMOTE_ADDR'];
 
// Look up the IP address and see if it's already submitted for your form (suggestion: check your FormId number is correct)
if (mysql_num_rows(mysql_query("SELECT `SubmissionID` FROM `jos_rsform_submissions` WHERE `UserIP`='".$rsip."' AND `FormId`='3' LIMIT 1")) > 0)
 
// If the IP address already exists, display alternative content for the form layout (suggestion: copy your thank you message)
$formLayout = 'You have completed this form already.';
 


Note that you need to change the FormId value to your Form number, and modify the value of $formLayout to what you want to have displayed instead of the form. In the form I created, it was to gather information before displaying videos to a client. The videos were displayed on the thank you message for the form, so my $formLayout field is set to the HTML contents of the thank you message.

You'll also need to be careful of ' " ` in your code, as this can cause a range of errors from incorrectly displaying HTML, through to what may be the cause of ashley.barnard and mutwirik3's problem - if the ' and ` are interchanged on the mysql statement, then it can cause the supplied argument error (or that's what I think is the first thing you should check).

Re:Setup form so each user can only submit once ? 6 hours, 1 minute ago #0

Hello,
This is an automatically generated message.
We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you wish to receive our support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here: http://www.rsjoomla.com/support-policy.html.

Thank You!
PLEASE NOTE: This topic is NOT locked and you can add replies to it. Other users are free to reply as well. This message has been generated by a bot and has no effect on the topic whatsoever.
  • Page:
  • 1
Moderators: alex, alexp, octavian, bogdanc, andreic
Time to create page: 2.66 seconds
Feedback