PHPMine
<? if(PHP > $Expectations) echo $Results ?>
by Angel S. Moreno
UNDER SOME SERIOUS CONSTRUCTION LINKS MAY NOT WORK
Asked 2010-03-09 00:07:37 by 24JJ24
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";
}}
?>
Hey thanks :) i'd really like to try that, but I need to rely on PhP validation incase people have Javascript turned and they can just bypass the validation :/
Turned off*
Anwered 2010-03-09 01:47:32 by dEviL cAlLeD mE dAd
ya well....i coded similar to tis...i had used ajax for validating n checking d email already present in d database .... it dynamically checks n response ,if d email id is available or not....if available ...then d email textbox clear it n prompts d user for another email id
try it wid ajax.....hope it helps ... ~~~~~ gud luck buddy!!!!
email me ...if u need code :)
Questions and answers provided by the Yahoo Answers Community.