Added valid_email() function for verifying email address syntax.
This commit is contained in:
@@ -950,4 +950,16 @@ function number_pad($number,$n) {
|
|||||||
return str_pad((int) $number,$n,"0",STR_PAD_LEFT);
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
Reference in New Issue
Block a user