Here is my code; I got the reg ex from a PHP book.
function is_email($email) {
// Checks for proper email format
if (! preg_match( '/^[A-Za-z0-9!#$%&\'*+-/=?^_`{|}~]+@[A-Za-z0-9-]+(\.[AZa-z0-9-]+)+[A-Za-z]$/', $email)) {
return false;
} else {
return true;
}
}
Now to test to see if the email is valid I am using:
if (is_email($_POST['email'])==TRUE){
echo 'valid email';
}
if (is_email($_POST['email'])==FALSE){
echo 'not valid email';
}
I must be missing something really basic. No matter what kinda email input it comes back as invalid.
Please someone show me the light.