Added valid_email() function for verifying email address syntax.

This commit is contained in:
Nate Jones
2014-07-03 23:19:30 +00:00
parent 6196d07edf
commit 25cdd980fc

View File

@@ -950,4 +950,16 @@ function number_pad($number,$n) {
return str_pad((int) $number,$n,"0",STR_PAD_LEFT);
}
// validate email address syntax
if(!function_exists('validate_email')) {
function valid_email($email) {
$regex = '/^[A-z0-9][\w.-]*@[A-z0-9][\w\-\.]+\.[A-z0-9]{2,6}$/';
if ($email != "" && preg_match($regex, $email) == 0) {
return false; // email address does not have valid syntax
}
else {
return true; // email address has valid syntax
}
}
}
?>