Hi,
I have a form with a field code, for server side validation I use the following script:
but I wanted to change my script so that if a user adds a code that does not exist in the database that it displays the error message:
code does not exist in our database, please select a valid code
Thank you in advance for your help
I have a form with a field code, for server side validation I use the following script:
<?php
$db =& JFactory::getDBO();
$code = JRequest::getString('text_0', '', 'post');
$query = "
SELECT COUNT(*)
FROM `jos_chronoforms_Passer_commande`
WHERE `text_0` = '$code' ;
";
$db->setQuery($query);
if ( $db->loadResult() ) {
$messages[] = "Sorry! Code is already used";
}
?>
but I wanted to change my script so that if a user adds a code that does not exist in the database that it displays the error message:
code does not exist in our database, please select a valid code
Thank you in advance for your help