Forums

Custom Server Side Validation chronoforms v4

yuki 02 Feb, 2012
Hi,
I created two textbox, how do I use the Custom Server Side Validation to ensure that it's the value entered is already in the database or not 😟
yuki 02 Feb, 2012
I use this code but ..😟

<?php
$i=0;
$db =& JFactory::getDBO();
$req = "SELECT cne from enregistrement";
$resultat = $db->query($req);
while ($row = $resultat->fetch()) {
if($row['cne']==$form->data['cne']) {
$form->validation_errors['cne'] = 'cne existe déja';
  $i++;
}

}

if ($i) {
  return false;
}
?>
GreyHead 02 Feb, 2012
Hi juki,

It looks as though you switched from Joomla! DB code to PHP DB code and the two don't join up properly
<?php
$db =& JFactory::getDBO();
$query = "
  SELECT COUNT(*)  
    FROM `enregistrement`
    WHERE `cne` = '{$form->data['cne']}' ;
";
$db->setQuery($query);
$resultat = $db->loadResult();
if ( $resultat ) {
  $form->validation_errors['cne'] = 'cne existe déja';
  return false;
}
?>

Bob
yuki 03 Feb, 2012
:D 😀 😀 thank youuuu very much it works (y)
This topic is locked and no more replies can be posted.