I have created a form and the results are stored in a table called "mkv_chronoforms_WEBkuulutused".
The form has one hidden field (along with a number of other fiels) and a random code-password is generated that is sent to the user by e-mail and also stored in the mentioned table. The field name is "hidden_O".
I want to be sure that the user has read the e-mail and has noticed the code. Therefore I have created a new form where the user needs to submit the e-mail address (text_0) again (the address the mail was sent to) and also the randomly generated code (text_1). The form is linked to another table where the info should be stored only, if the code entered in text_1 field matches the one in the mkv_chronoforms_WEBkuulutused hidden_0 field.
If the code is entered incorrectly, the user gets an error message and the data will not be submited. If it is correct, then the form will be submitted.
I am not a programmer and I have managed to create all forms (including the random generated code) by the help of this forum. I have gone through most of the posts about validation but cant get this to work.
Tried the following code that I found in one of the posts to add to the server-side validation box but nothing happens.
Anyway, this code should prevent from submitting the form if the field entered matches one of the fields in the database but I want to do the exact opposite. I only want the data in a table if the user has gotten the e-mail, has noticed the random-code that was sent and has validated this by entering the code to the new form correctly.
What am I doing wrong?
The form has one hidden field (along with a number of other fiels) and a random code-password is generated that is sent to the user by e-mail and also stored in the mentioned table. The field name is "hidden_O".
I want to be sure that the user has read the e-mail and has noticed the code. Therefore I have created a new form where the user needs to submit the e-mail address (text_0) again (the address the mail was sent to) and also the randomly generated code (text_1). The form is linked to another table where the info should be stored only, if the code entered in text_1 field matches the one in the mkv_chronoforms_WEBkuulutused hidden_0 field.
If the code is entered incorrectly, the user gets an error message and the data will not be submited. If it is correct, then the form will be submitted.
I am not a programmer and I have managed to create all forms (including the random generated code) by the help of this forum. I have gone through most of the posts about validation but cant get this to work.
Tried the following code that I found in one of the posts to add to the server-side validation box but nothing happens.
<?php
$hidden_0 = JRequest::getVar('text_0', '', 'post');
$db =& JFactory::getDBO();
$query = "
SELECT count(*)
FROM `#mkv_chronoforms_WEBkuulutused`
WHERE `hidden_0` = ".$db->Quote($hidden_0)." ;
";
$db->setQuery($query);
if ( $db->loadResult()) {
return "Error message";
}
?>
Anyway, this code should prevent from submitting the form if the field entered matches one of the fields in the database but I want to do the exact opposite. I only want the data in a table if the user has gotten the e-mail, has noticed the random-code that was sent and has validated this by entering the code to the new form correctly.
What am I doing wrong?