• 1

Read this first!

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 have an active subscription and wish to receive 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.

Thank you!

TOPIC: SOLVED - Script for single submission of form

SOLVED - Script for single submission of form 16 years 8 months ago #4082

Hello,

I have forms that only registered users fill.
They are allowed to submit these forms only once, but if they use the browser \"back\" button (or reload the page from the history), they can submit it as often as they want.

I know that if I insert a script in the form I can prevent that, but i am not yet very good in PHP so I'd appreciated if someone could write it for me.

PS : I use RSForm!Pro for Joomla! 1.0.15

Post edited by: jean-francois.questiaux, at: 2008/08/12 08:58<br><br>Post edited by: jean-francois.questiaux, at: 2008/08/23 14:13
The administrator has disabled public write access.

Re:Script for single submission of form 16 years 8 months ago #4416

I tried to write it myself, so this is what I've done :

global $database, $my; $my-&gt;$uid; $query = \&quot;SELECT FormId FROM #__RSFORM_SUBMISSIONS WHERE UserId = '$uid' \&quot;; $database-&gt;setQuery($query); $test = $database-&gt;loadResult(); if ( $test != 0 ) { mosRedirect( \&quot;index.php?option=com_enquete&amp;task=test_ko&amp;Itemid=17\&quot;[code]global $database, $my;

$my->$uid;

$query = \"SELECT FormId FROM #__RSFORM_SUBMISSIONS WHERE UserId = '$uid' \";
$database->setQuery($query);
$test = $database->loadResult();

if ( $test != 0 ) {

mosRedirect( \"index.php?option=com_enquete&task=test_ko&Itemid=17\"
The administrator has disabled public write access.

Re:Script for single submission of form 16 years 8 months ago #4417

  • dragonjc
  • dragonjc's Avatar
  • OFFLINE
  • Expert Boarder
  • Posts: 151
Try this
global $database, $my; $mydata = $my-&gt;uid; $query = \&quot;SELECT FormId FROM #__RSFORM_SUBMISSIONS WHERE UserId = '$mydata' \&quot;; $database-&gt;setQuery($query); $test = $database-&gt;loadResult(); if ( $test != 0 ) { mosRedirect( \&quot;index.php?option=com_enquete&amp;task=test_ko&amp;Itemid=17\&quot;[code]global $database, $my;

$mydata = $my->uid;

$query = \"SELECT FormId FROM #__RSFORM_SUBMISSIONS WHERE UserId = '$mydata' \";
$database->setQuery($query);
$test = $database->loadResult();

if ( $test != 0 )
{
mosRedirect( \"index.php?option=com_enquete&task=test_ko&Itemid=17\"
Component RS SHow Form in build
The administrator has disabled public write access.

Re:Script for single submission of form 16 years 8 months ago #4418

Thank you dragonjc. I was hoping that you would help !

Is is better since the error is gone but the script is not working in the sense that at the moment, when someone submit a form, he is rederected to a page (like the \"thank you\" page) But if he uses the \"back\" button of the brower, he is presented with the form again and free to submit it again... and again... and again.

I put the script in the post treatment script of the form but it is not working.

I suspect that if the FormId is not present in the table, the result of $test is not \"0\", but then what is it ?<br><br>Post edited by: jean-francois.questiaux, at: 2008/08/22 16:45
The administrator has disabled public write access.

Re:SOLVED - Script for single submission of form 16 years 8 months ago #4429

OK, I found it !

This is the code that works :

global $database, $my; $mydata = $my-&gt;id; $currentformid = $RSadapter-&gt;getParam($_GET,'formId',0); $query = \&quot;SELECT FormId FROM #__RSFORM_SUBMISSIONS WHERE UserId = '$mydata' \&quot; . \&quot;\n AND FormId = '$currentformid'\&quot;; $database-&gt;setQuery($query); $test = $database-&gt;loadResult(); if ( $test != 0 ) { mosRedirect( \&quot;adress_of_the_page_with_error_message\&quot;[code]global $database, $my;

$mydata = $my->id;
$currentformid = $RSadapter->getParam($_GET,'formId',0);

$query = \"SELECT FormId FROM #__RSFORM_SUBMISSIONS WHERE UserId = '$mydata' \"
. \"\n AND FormId = '$currentformid'\";
$database->setQuery($query);
$test = $database->loadResult();

if ( $test != 0 ) {

mosRedirect( \"adress_of_the_page_with_error_message\"
The administrator has disabled public write access.
  • 1

Read this first!

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 have an active subscription and wish to receive 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.

Thank you!