• 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: Code to limit submissions no longer works

Code to limit submissions no longer works 3 months 2 weeks ago #43198

I've been using the following code in a form for the past 10 years. With the change to J4 and PHP 8.1.27 it no longer limits the submissions to 1. Is there something that needs to be updated in the code? (I'm not a programmer - just an RSJoomla component user for years). If there is, could you post what needs to be changed? I can copy and paste if I know where the change needs to be made. Thanks.
(Getting tired of having to delete all the pile-on votes on the form)

// Define the maximum number of submissions.
$max = 1;

// Get the current IP address.
$ip = $_SERVER;

// Get the database connection.
$db = JFactory::getDbo();

// Setup the query.
$db->setQuery("SELECT COUNT(`UserIp`) FROM `#__rsform_submissions`
WHERE `UserIp`='".$db->escape($ip)."'
AND `FormId`='".(int) $formId."'");
$counter = $db->loadResult();

if ($counter >= $max){
$formLayout = '<p style="color:red;">Sorry, only one vote per user is allowed.</p>';
}
The administrator has disabled public write access.

Code to limit submissions no longer works 3 months 1 week ago #43220

  • dragos
  • dragos's Avatar
  • OFFLINE
  • Administrator
  • Posts: 564
  • Thank you received: 102
Hello,

You can try taking a look at the example nr 3 from this article.
The administrator has disabled public write access.

Code to limit submissions no longer works 3 months 1 week ago #43224

Just added the code in the #3 section (IP address) of the article, changed the limit to 1 and since I had voted before, I tried it. Still allowed me to submit and didn't give the message.
I'll continue to monitor since there is someone out there who is trying to vote often. Right now, I'm just deleting duplicate IP submissions. And I'll recheck to make sure I put the code in the right place.
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!