note 36538 deleted from function.eregi by didou
| From: | didou@php.net | Date: | Tue, 30 Dec 2003 14:31:34 +0000 |
| Subject: | note 36538 deleted from function.eregi by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-62676@lists.php.net to get a copy of this message | ||
Note Submitter: c0p0n.antisp@m.myrealbox.com
----
a simple email validation function:
<?
function validate_email($string)
{
//checking that there is only one @, and that there are more than zero chars on both sides of the @
symbol
list( $name, $address) = split( "@", $string );
if ( (strlen($name) >= 1) && (strlen($address) >= 1))
{
//if the first @ position and the last @ position are on the same char,
//there is only one @ on the original email address (r00lez!)
$a = strrpos($string, '@');
$b = strpos($string, '@');
if ($a == $b)
{
//so, if the above is ok, let's check the address
list( $domain, $type) = split( ".", $address );
//it does NOT check if the second is a .com, .es or something like that. it only checks that there
is an
//apparently valid domain on $address (domain.type, or subdomain.domain). you can combine this
//function with others on this thread to complete that task...
if ( (strlen($domain) >= 1) && (strlen($type) >= 1) )
return(1); //all the above is correct, the email appears to have a valid syntax
}
else
return(0);
}
else
return(0);
}
?>
it does check that the email syntax is correct. it does not check if the domain exists, or the
domain type is correct. just to be merged with functions to do that.