• 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: Limiting submissions per user

Limiting submissions per user 12 years 7 months ago #14870

  • Steve02
  • Steve02's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
Hi,

I was given this script to limit the number of times a user can submit to a form. It does not appear to be working. Is there something about this script which needs to be changed or do you have a better script for me to use to accomplish the same goal?
The form id '3' is correct and I tried limiting using different numbers than '1' with no success.


// Determine the IP address for the user
$rsip =$_SERVER;

// 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.';



I already have the following script in the form to limit the total number of submissions to a form and it seems to be working fine. I thought there might be a conflict between scripts so I tried the above script alone and it still did not work.

global $database;
$database = JFactory::getDBO();
$database->setQuery("SELECT COUNT(`SubmissionId`) FROM jos_rsform_submissions WHERE `formId`='3'");
$database->query();
if (intval($database->loadResult()) >= 20)
{
echo 'Sorry, All the passes for this screening have been distributed! Watch your emails for upcoming screenings. Best of Luck!';
$formLayout = '';
}

Thank you in advance for any help you can give.

Steve
The administrator has disabled public write access.

Re: Limiting submissions per user 12 years 7 months ago #14889

  • Steve02
  • Steve02's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
Hi,

I was able to get the limit number of submissions script to work properly.

I used this script to limit each submission to one member. I copied it from the custom scripts page:

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

When validation fails it does not take the user to the 'error' page I set up. It takes the user to the administration log in page of my website. How can I get the failed validation to go to my error page?

Thanks,

Steve
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!