function validateemail($email) {
$v = "/[a-zA-Z0-9_-.+]+@[a-zA-Z0-9-]+.[a-zA-Z]+/";
return (bool)preg_match($v, $email);
}
// check e-mail address, to see if it's a valid phone number
if ($validateemail($email)) {
$error = true;
echo 'Invalid phone number!';
}
I'm trying to check if an e-mail address is valid by the function validateemail
, if it's an invalid phone number a message is displayed and $error
is set to true. However I can't seem to get this code to work, there are no syntax errors as far as I know. Any advice would be appreciated.
BTW - I know there are other ways to validate e-mail addresses, this is for a college project and for that purpose we have to use regex.
Thanks in advance!