Thanks for your help VirtuosiMedia
Your code looks like it should work and I think it does but when the code executes $status can get set to NOTOK and then later get set to OK again, I have spent hours on this now trying to get it to work lol
It should check each email address entered by the user, make sure there is at least one email address entered ($email1), check the email address isn't already registered to an account, display error messages if the first email has not been entered or if any of the other emails that have been entered have an invalid format.
I bet this is prob a really easy thing to do in PHP and I'm not getting the logic right, maybe if I used more $status checks like $email1status="NOTOK" etc
This is the code I'm using:
PHP Code:
$status = "NOTOK"; $msg=""; if($email1==""){ $msg=$msg."<img src='error.png'> You must enter at least one email address<BR>"; $status= "NOTOK";} if(!email1==""){ if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email2)){ $msg=$msg."<img src='error.png'> Invalid email address 2<BR>"; $staus="NOTOK"; }} if(!$email2=="" && !$email1==""){ if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email3)){ $msg=$msg."<img src='error.png'> Invalid email address 3<BR>"; $staus="NOTOK"; }} if(!$email1=="" && !$email2=="" && !email3==""){ if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email4)){ $msg=$msg."<img src='error.png'> Invalid email address 4<BR>"; $staus="NOTOK"; }} if(!$email1==""){ if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email1)){ $msg=$msg."<img src='error.png'> Invalid email address 1<BR>"; $staus="NOTOK";} else { $staus="OK";}} if(mysql_num_rows(mysql_query("SELECT * FROM users WHERE email = '$email1'"))){ $msg=$msg."$email1 is already registred to an account<BR>"; $status= "NOTOK";} if(mysql_num_rows(mysql_query("SELECT * FROM users WHERE email = '$email2'"))){ $msg=$msg."$email2 is already registred to an account<BR>"; $status= "NOTOK";} if(mysql_num_rows(mysql_query("SELECT * FROM users WHERE email = '$email3'"))){ $msg=$msg."$email3 is already registred to an account<BR>"; $status= "NOTOK";} if(mysql_num_rows(mysql_query("SELECT * FROM users WHERE email = '$email4'"))){ $msg=$msg."$email4 is already registred to an account<BR>"; $status= "NOTOK";} if($status<>"OK"){ echo "<font face='arial' color=red>$msg<center> <img src='error.png'> Invites were not sent </font><br><br><input type='button' value='Go back' onClick='history.go(-1)'></center>"; }else{ // if all validations are passed. //$query=mysql_query("select * from plus_signup where userid = '$userid)"); echo "<font face='arial' color=green><br><img src='success.png'> Click the button below to send invites.<br><br></font>";
Last edited by drew22299 : 05-01-2008 at 04:48 AM.
|