|
Posted by Philip Ronan on 11/16/21 11:29
"laredotornado@zipmail.com" wrote:
> Hello, Could someone point me to a PHP 4 function that validates that
> an email address is of the right form?
>
> Thanks for your help, - Dave
>
This is what I use:
function checkEmailSyntax($em)
{
$re_bad = '/(@)|(\.\.)|(^\.)|(\.$)/';
$re_ok1 = '/^[^\x00-\x1f <>\x22\x7f]+$/';
$re_ok2 = '/^([A-Za-z0-9\-_]+\.){1,5}[A-Za-z]{2,5}$/';
$t_split = explode("@",$em);
if (count($t_split) == 2) {
$t_name = $t_split[0];
$t_domain = $t_split[1];
if ( !preg_match($re_bad, $t_name) &&
preg_match($re_ok1, $t_name) &&
!preg_match($re_bad, $t_domain) &&
preg_match($re_ok2, $t_domain) ) {
return true;
}
}
return false;
}
--
phil [dot] ronan @ virgin [dot] net
http://vzone.virgin.net/phil.ronan/
[Back to original message]
|