So I am trying to validate email addresses before submitting them to a database. I pass the variable $email to my action script. Here is the code I have so far:
if (isset($email))
return (ereg('[-!#$%&\'+\./0-9=?A-Za-z{|}~]+'. '@'. '[-!#$%&\'*+\\/0-9=?A-Z^_a-z{|}~]+.' . '[-!#$%&\'*+\./0-9=?A-Z`a-z{|}~]+$', $email));
localConnect();
MySQL_query("insert into table_1(field1, field2) values ('$email', '$value');");
Now I know this is incorrect, what am I supposed to do with the return(ereg(..) code so that it returns a value based on the $email variable? Any help will be much appreciated.