Hi,
I am trying to get some code straight. I know its a bit messy, apologies. The aim of the script is that if the email matches a regex expression (previously defined), then it checks the database to see if the email the user has entered is already there. If it is, it prints back a message telling the user to enter a new one.
The database field itself is unique, so technically there will be no other email that is the same, however for the sake of having to redirect the user back I'd like to just keep all the validation on one page.
However, when I enter an email that already exists in the database, it still lets me continue to the database page. Not sure why this is, can anyone help me out?
Thanks
--------------------------------------…
$email = clean($_POST['Email1']);
<tr>
<td><div class="<?php print $emailclass; ?>">Email Address:*</div></td>
<td><input type="text" name="Email1" value="<?php print $email; ?>" size="30"/></td>
</tr>
<?php
if ($emailvalidationcheck == "NOTOK"){
$flag = "NOTOK";
print '<tr><td align="center" colspan="2" class="errorsubtext"> Please enter a valid Email Address. </td></tr>';
}
else if ($emailvalidationcheck == "OK"){
$sql = "select count(*) from `".$tbl_name."` where `customer_email_address` = '" .mysql_real_escape_string($email). "'";
$list = mysql_query($sql);
$lst = mysql_fetch_array($list);
$count = $lst[0];
mysql_free_result($list);
if($count >= 1){
$emailclass = "errortext";
$flag="NOTOK";
print '<tr><td align="center" colspan="2" class="errorsubtext"> This email address is already in use. </td></tr>';
}
else if($count ==0){
$emailclass = "basictext";
$flag="OK";
}}
?>
I am trying to get some code straight. I know its a bit messy, apologies. The aim of the script is that if the email matches a regex expression (previously defined), then it checks the database to see if the email the user has entered is already there. If it is, it prints back a message telling the user to enter a new one.
The database field itself is unique, so technically there will be no other email that is the same, however for the sake of having to redirect the user back I'd like to just keep all the validation on one page.
However, when I enter an email that already exists in the database, it still lets me continue to the database page. Not sure why this is, can anyone help me out?
Thanks
--------------------------------------…
$email = clean($_POST['Email1']);
<tr>
<td><div class="<?php print $emailclass; ?>">Email Address:*</div></td>
<td><input type="text" name="Email1" value="<?php print $email; ?>" size="30"/></td>
</tr>
<?php
if ($emailvalidationcheck == "NOTOK"){
$flag = "NOTOK";
print '<tr><td align="center" colspan="2" class="errorsubtext"> Please enter a valid Email Address. </td></tr>';
}
else if ($emailvalidationcheck == "OK"){
$sql = "select count(*) from `".$tbl_name."` where `customer_email_address` = '" .mysql_real_escape_string($email). "'";
$list = mysql_query($sql);
$lst = mysql_fetch_array($list);
$count = $lst[0];
mysql_free_result($list);
if($count >= 1){
$emailclass = "errortext";
$flag="NOTOK";
print '<tr><td align="center" colspan="2" class="errorsubtext"> This email address is already in use. </td></tr>';
}
else if($count ==0){
$emailclass = "basictext";
$flag="OK";
}}
?>