Max,
I'm trying to do the server side validation for an email. I'm using the following code in the server side validation code box but it doesn't seem to work.
<?php
$ref_num = JRequest::getVar('text_4', '', 'post');
$db =& JFactory::getDBO();
$query = "
SELECT count(*)
FROM `#__users`
WHERE `ref_num` = ".$db->Quote($quote)." ;
";
$db->setQuery($query);
$in_use = $db->loadResult();
if ( $in_use) {
return "That email is already registered, please try again";
}
?>
I'm trying to do the server side validation for an email. I'm using the following code in the server side validation code box but it doesn't seem to work.
<?php
$ref_num = JRequest::getVar('text_4', '', 'post');
$db =& JFactory::getDBO();
$query = "
SELECT count(*)
FROM `#__users`
WHERE `ref_num` = ".$db->Quote($quote)." ;
";
$db->setQuery($query);
$in_use = $db->loadResult();
if ( $in_use) {
return "That email is already registered, please try again";
}
?>
Hi spelcher,
A bit late for me but I think that
Bob
A bit late for me but I think that
WHERE `ref_num` = ".$db->Quote($quote)." ;
should be WHERE `ref_num` = ".$db->Quote($ref_num)." ;
as $quote isn't defined here.Bob
thanks. I've changed that but no success yet.
I got this code from one of Max's posts on preventing duplication of table entries.
I got this code from one of Max's posts on preventing duplication of table entries.
Hi spletcher,
The second problem is that there isn't a field called ref_num in jos_users, the email field is `email` so the code needs to be
Bob
The second problem is that there isn't a field called ref_num in jos_users, the email field is `email` so the code needs to be
<?php
$email = JRequest::getVar('text_4', '', 'post');
$db =& JFactory::getDBO();
$query = "
SELECT count(*)
FROM `#__users`
WHERE `email` = ".$db->Quote($email)." ;
";
$db->setQuery($query);
if ( $db->loadResult()) {
return "That email is already registered, please try again";
}
?>
Bob
This topic is locked and no more replies can be posted.