Forums

Submission limits

SPABO 02 Jun, 2010
Hope someone knows the solution or how to fix

In a form I have put in at Submissions limit (in sec) 604800 (7 days)
The form can only be filled out once logged in.
If the users tays logged in, it wordks fine, but...........

When he logs out and directly logs in again, the form again can be filled out.....

In JOOMLA global settings
CACHE : No
Session time: 25 min
Sessionhandler: Database
GreyHead 02 Jun, 2010
Hi SPABO,

What are you actually trying to do here?

I think that the Submissions limit is only intended for short delays of a few minutes to prevent spam flooding or repeated clicking. The info is stored in the session so is lost if the session is lost.

Bob
SPABO 02 Jun, 2010
Hey Bob
The form is ment a to register for a game, but to limit the number of "double registrations", I would like to have a timeslot of eg 7 workingdays.

I read in the menan time all the available tutorials, the solution could be to ceate and connect to a (form)table.

What do you think ?? Should this work ??
GreyHead 02 Jun, 2010
Hi SPABO,

Yes, connect the form to a table then check the table when the form is submitted. If they aren't logged in then you'll need to decide what to check, email address is usually good.

Bob
SPABO 02 Jun, 2010
Bob
This is not what I'm looking for as there several kinds of registrationsforms
FYI
Only is a user has logged is, he will see the forms
The frms are pre-loaded with data from Comm.Builder (I'm sure you remember my topics on this)

I understand, once the user has logged out, the "sumission limit counter" resets, in other words, when logged out and than logged in, the users can submit again.

May you have an idea how to "lock" a form for a users during x days, after submitting??
GreyHead 02 Jun, 2010
Hi SPABO,

If they are logged in then create a little table with 'user_id', 'form_id', and 'date'.

Then in the Form HTML add a query to this table to check
WHERE `user_id` = ".$user->id."AND `form_id` = '$form_id' AND DATEDIFF(`date`, CURDATE()) > 7 
Done from memory so will be buggy, check the correct syntax carefully.

Bob
SPABO 02 Jun, 2010
Bob
Not sure what you are saying, a user to create a small table?
Or should this be added in the formrelated table?
SPABO 02 Jun, 2010
Pls keep us posted !!!
GreyHead 02 Jun, 2010
Hi SPABO,

I'd probably use a separate table if starting from scratch but if you already have a form related table then all the info you need is probably there. Check cf_user_id and recordtime.

Bob
SPABO 02 Jun, 2010
Indeed both are in the the table, so would it be like this on top in the HTML code?

<?php
WHERE `cf_user_id` = ".$user->id. " AND `form_id` = '$form_id' AND DATEDIFF(`recordtime`, CURDATE()) > 7 
?>
SPABO 02 Jun, 2010
PARSE ERROR

Parse error: syntax error, unexpected '`' in /home/xxxxx/domains/xxxxxxxxxxxxxxx.nl/public_html/components/com_chronocontact/chronocontact.html.php(180) : eval()'d code on line 2
GreyHead 02 Jun, 2010
Hi SPABO,

It needs to be part of a MySQL query.

Bob
SPABO 02 Jun, 2010
I'm lost now (again)
SPABO 03 Jun, 2010
Bob,
Would it make sense to have a query in the Validation tab??

In the mean time I put this in, but I'm getting an unexpected T_STRING on line 5

<?php
$user =& JFactory::getUser();
$db =& JFactory::getDBO('jos_chronoforms_JEUGD); //this is teh related table
$user_info = $db->loadObject();
$then = JFactory::getDate(JRequest::getString('recordtime'));//<<<<< ???????
$now = JFactory::getDate();
$diff = $then->toUnix() - $now->toUnix();
if ($diff < 7*24*60*60) {             //// 7 is nbr of days
  return '- Sorry, etc etc etc!';
}
?>


Or I'm thinking in a totally wrong direction???
GreyHead 03 Jun, 2010
Hi SPABO,

The error message is probably from the missing quote in line 3. But that said the code looks like a mess.

It needs to go into the Form HTML, not the server side validation tab as you want to check before the form is loaded.
<?php
if ( !$mainframe->isSite() ) { return; }
$user =& JFactory::getUser();
$db =& JFactory::getDBO(); 
$query = "
  SELECT COUNT(*) 
    FROM `jos_chronoforms_JEUGD`
    WHERE `cf_user_id` = '".$user->id."'
      AND DATEDIFF(CURDATE(), CAST(`recordtime` AS DATE)) < 7 ;
";
$db->setQuery($query);
$check = $db->loadResult();
if ( $check) {
  echo "Sorry, you have already registered in the last week";
  return;
} 
?>
// normal form html

Not tested and will need debugging

Bob
SPABO 03 Jun, 2010
Bob
I was just trying๐Ÿ˜ถ
Debugging ???? It went exactly as what I had in my mind!๐Ÿ˜€ ๐Ÿ˜€
GREATT
Thanks very very much Bob !!!
SPABO 06 Jun, 2010
Indeed it is as Bob wrote !!๐Ÿ˜€
This topic is locked and no more replies can be posted.