Possible Duplicate:
How to validate an email in php5?
I have used the following code to ensure email addresses provided on signup are valid.
(!preg_match("/^( [a-zA-Z0-9] )+( [a-zA-Z0-9\._-] )*@( [a-zA-Z0-9_-] )+( [a-zA-Z0-9\._-] +)+$/" , $email))
I entered a standard email address such as
and it is flagging up as being invalid.
Can anyone help me with why this may be happening?
Why not just use filter_var
var_dump(filter_var($email,FILTER_VALIDATE_EMAIL));
EDIT
if(filter_var($email,FILTER_VALIDATE_EMAIL) === false)
{
echo 'Email is not valid';
}
else
{
//do the stuff
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With