24JJ24
2010-03-07 23:59:27 UTC
Here is a snippet of code from a form I have. I am trying to validate an email address field, the validation all goes through just fine, as far as the regex expression I am using is concerned and if an unmatching or invalid email address is entered, the statment "Please enter a valid email address" is printed back.
However I am trying to test wether an email address is already in use in the database, and I think my MySQL query syntax is correct, at least I can't think of another way to put it. Can anyone set me straight on this?
Thanks,
Email Address:*
if ($emailvalidationcheck == "NOTOK"){
$flag = "NOTOK";
print '
}
else if ($emailvalidationcheck == "OK"){
$emailquery = "SELECT * FROM $tbl_name WHERE customers_email_address='$email'";
$result = mysql_query($emailquery);
$count = mysql_num_rows($result);
if($count==1){
$emailclass = "errortext";
$flag="NOTOK";
print '
}
else if($count==0){
$emailclass = "basictext";
$flag="OK";
}}
?>