PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
public static function validateEmail($email) {
$errors = array();
if(!empty($email)) {
if(!System_Validator::isValidEmailAddress($email)) {
$errors[] = 'Invalid email address';
}
} else {
$errors[] = 'You must provide an email address';
}
return $errors;
}
public static function isValidEmailAddress($email) {
// Regex from regular-expressions.info
$regex = '/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}/';
if(preg_match($regex, $email)) {
return true;
}
return false;
}
When I type in trooper@gmail.com as the email address, it tells me that the address is "invalid". I think it's safe to assume the regex is not the issue.