Hi Bob, Hope you can help me again.
I'm trying to validate if somebody with a spcfic e-amailaddress already has subscribed for an event with a spcific date.
I have this in now in Custom Server Side Validation before the e-mail ( including teh Event loop)
But it is'n working
I'm trying to validate if somebody with a spcfic e-amailaddress already has subscribed for an event with a spcific date.
I have this in now in Custom Server Side Validation before the e-mail ( including teh Event loop)
But it is'n working
<?php
$datum = JRequest::getString('datum', '', 'post');
$email = JRequest::getString('email', '', 'post');
if ($datum){
$db =& JFactory::getDBO();
$query = "
SELECT *
FROM `j17_chronoforms_data_INSCHRIJF_PP`
WHERE `datum` = '$datum'
AND `email` = '$email';
";
$db->setQuery($query);
if ($db->loadResult()==False);
$form->validation_errors['datum'] = "Sorry, etc etc etc .";
return false;}
?>
Her it is, again I missed a }
<?php
$datum = JRequest::getString('datum', '', 'post');
$user_info = JRequest::getString('email', '', 'post');
if ($datum){
$db =& JFactory::getDBO();
$query = "
SELECT *
FROM `j17_chronoforms_data_INSCHRIJF_PP`
WHERE `datum` = '$datum'
AND `email` = '$user_info';
";
$db->setQuery($query);
if ($db->loadResult()==True) {
$form->validation_errors['email'] = "Helaas, etc etc .";
return false;
}}
?>
Hi SPABO,
I just noticed the missing {
Here's how I would write it
Bob
I just noticed the missing {
Here's how I would write it
<?php
$datum = JRequest::getString('datum', '', 'post');
$user_info = JRequest::getString('email', '', 'post');
if ( $datum && $user_info ) {
$db =& JFactory::getDBO();
$query = "
SELECT COUNT(*)
FROM `#__chronoforms_data_INSCHRIJF_PP`
WHERE `datum` = '{$datum}'
AND `email` = '{$user_info}';
";
$db->setQuery($query);
$count = $db->loadResult();
if ( $count > 0 ) {
$form->validation_errors['email'] = "Helaas, etc etc .";
return false;
}
}
?>Bob
It works nicely as well Bob, but I'm prety sure you have a reason, or is it just a matter of "simplification"?
By the way, to get rid of the "error-message" in the field, just wipe out teh fieldname
Old
New
Hope this could be usefull to know
By the way, to get rid of the "error-message" in the field, just wipe out teh fieldname
Old
$form->validation_errors['fieldname'] = "Sorry etc etc .";
return false;}New
$form->validation_errors[''] = "Sorry etc etc .";
return false;}
Hope this could be usefull to know
Hi SPABO,
I think it is this line that won't work in your code:
Bob
I think it is this line that won't work in your code:
if ($db->loadResult()==True) {Bob
This topic is locked and no more replies can be posted.
