Chrono forms for competitions

monstermike 21 Apr, 2010
Hi Guys

"Well done on such a great component, definitely one of the best ones out there."

I need to run a competition on a website of mine which has a number of text fields and radio buttons, Chrono forms does this beautifully, but what i need to find out is: Is there a setting in chronoforms that will not allow the same user to enter the competition twice so for example, a user cannot enter the competition twice based on their cellphone number that is submitted through chronoforms and saved into the database. Is there a setting that will check a specific field in the database for a duplicate entry and if there is duplicate entry based on that field it does not allow the user to re-submit the form with an error message.

Any help or advice with this matter will be great, if i have been unclear here please feel free to ask me to supply more details.

Regards

monstermike
GreyHead 21 Apr, 2010
Hi monstermike,

There is no setting in ChronoForms that will do this for you. But you can add code to check easily enough. I can think of three options.

a) Least reliable, you could add a cookie but it will only work if the user re-tries on the same computer.

b) You could add a server-side validation check to look a value up on the database and reject the sumbission if a match is found.

c) Neatest but most complex, you could add an Ajax look up in the form to check when the field is completed.

Bob
monstermike 21 Apr, 2010
Thanks you for the super fast reply

I know it is a bit of a tricky one, a cookie will be out of the question but i am interested in point number 2 that you have listed here.

I am a little bit shaky with regards to this but i try, this may seem like a silly question but where would i even start with with "add a server-side validation check to look a value up on the database and reject the sumbission if a match is found." would this require me to change any core code within chronoforms to manage that submit.

Regards
GreyHead 21 Apr, 2010
Hi monstermike,

You need to add code in the ServerSide Validation box on the Validation tab in the Form Editor.
It will be something like this
<?php
$db =& JFactory::getDBO();
$some_input = JRequest::getString('some_input', '', 'post');
if ( !$some_input ) {
  return 'Some_input is required';
}
$query = "
  SELECT count(*) 
    FROM `#__some_table`
    WHERE `some_column` = '$some_input' ;
";
$db->setQuery($query);
$count = $db->loadResult();
if ( $count) {
  return 'This Some_input is already registered';
}
?>

Bob
monstermike 21 Apr, 2010
Thank you so much for this -- officially purchasing chronoforms !

Regards

monstermike
This topic is locked and no more replies can be posted.