Possible Duplicate:
E-mail validation in php? please help
I have Ajax sign up form. The code checks if the email exists in mysql, if it does, it says "sorry your email exists" - otherwise it will insert the email into mySQL.
How do I check to see if they have inserted a valid email? Like a rule char@ext
<?php
$con = mysql_connect("localhost","user","pass");
mysql_select_db("mytable", $con);
if(isset($_GET['email'])){
$e= $_GET['email'];
$cc= mysql_real_escape_string($e);
$r = mysql_query("SELECT * FROM `maillist` WHERE `email` = '".$cc."'");
if (mysql_affected_rows()==0) {
$r = mysql_query('INSERT INTO maillist (id, email) VALUES(NULL,"'.$cc.'")');
echo $cc;
} else {
echo 'Your email already exists!';
}
}
mysql_close($con);
?>