Forums

Using ChronoForms V5 is it possible to only allow 1 submission per email address?

arun 16 Nov, 2016
I'm using ChronoForms V5 on Joomla 3.

I'd set up a form for people to enter a competition, the form sends the data entered into a new table in the MySQL database. This all works.

My question is, how can I make it so only 1 entry can be submitted per email address? I'd like to prevent multiple entries from the same email address.

Many thanks
GreyHead 16 Nov, 2016
Hi arun,

Use an Event Switcher in the On Submit event of your form. Add a couple of lines of PHP there to check if the address is already registered - something like this
<?php
$db = \JFactory::getDBO();
$query = "
    SELECT COUNT(*)
        FROM `#__table_name`
        WHERE `email` = '{$form->data['email}']' ;
";
$db->setQuery($query);
$count = $db->loadResult();
if ( $count >= 1 ) {
  return 'fail';
} 
?>

Bob
GreyHead 16 Nov, 2016
Hi arun,

Use an Event Switcher in the On Submit event of your form. Add a couple of lines of PHP there to check if the address is already registered - something like this
<?php
$db = \JFactory::getDBO();
$query = "
    SELECT COUNT(*)
        FROM `#__table_name`
        WHERE `email` = '{$form->data['email}']' ;
";
$db->setQuery($query);
$count = $db->loadResult();
if ( $count >= 1 ) {
  return 'fail';
} 
?>

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