How can I prevent a guest from submitting twice, a public chronoform??? In other words, how can I check that a certain e-mail address has submitted this form?
Forums
prevent duplicate submission
Hi mariospapa,
You can use Server Side validation to check if the Email is already in the data table.
Bob
You can use Server Side validation to check if the Email is already in the data table.
Bob
Hi mariospapa,
You can use Server Side validation to check if the Email is already in the data table.
Bob
Thank you Bob,
and how can i write a simple php script in order to check if an e-mail exists, when i have Database0 with Table0 and name, email are the two fields of the Table0?
I wrote code below and put it to "ServerSide Validation" of chronoform and enable the corresponding option!
But it doesn't work! Why?
<?php
mysql_connect ("localhost", "user","password") or die (mysql_error());
mysql_select_db ("database");
$checkmail = $_POST['email'];
$res = mysql_query("SELECT email FROM Table1 WHERE email = '$checkmail');
if(mysql_num_rows($res) != 0) {
echo 'You have already submit the current form';
}
?>
But it doesn't work! Why?
Hi Mariospapa,
The code isn't very Joomla! and the ServerSide validation needs to set a 'return' value if there is an error (see the example on the ToolTip). Is your table really called Table1?
Please try:
Bob
The code isn't very Joomla! and the ServerSide validation needs to set a 'return' value if there is an error (see the example on the ToolTip). Is your table really called Table1?
Please try:
<?php
$checkmail = JRequest::getString('email', '', 'post');
$db =& JFactory::getDBO();
$query = "
SELECT COUNT(`email`)
FROM `Table1`
WHERE `email` = '$checkmail' ;
";
$db->setQuery($query);
$count = $db->loadResult();
if ( $count ) {
return 'You have already submit the current form';
}
?>
Bob
Hey Bob... thank you for helping me...
The code that you provide me, doesn't work... I think that by submission of the form, the whole thing doesn't pass from this validation code... The real name of the table that contains email field is "jos_chronoform_form1".
The code that you provide me, doesn't work... I think that by submission of the form, the whole thing doesn't pass from this validation code... The real name of the table that contains email field is "jos_chronoform_form1".
Hi mariospapa,
It's fairly standard validation and it should work OK unless I've left typos in there. The FROM line probably becomes FROM `#__chronoforms_form1`
Bob
It's fairly standard validation and it should work OK unless I've left typos in there. The FROM line probably becomes FROM `#__chronoforms_form1`
Bob
This one is working great! You have forgotten one comma in JRequest::getString...
Thanks for helping me again!
<?php
$checkmail = JRequest::getString('email', '', 'post');
$db =& JFactory::getDBO();
$query = "
SELECT COUNT(`email`)
FROM `#__chronoforms_form1`
WHERE `email` = '$checkmail' ;
";
$db->setQuery($query);
$count = $db->loadResult();
if ( $count ) {
return 'You have already submit the current form';
}
?>
Thanks for helping me again!
This topic is locked and no more replies can be posted.