RE: [PHP] E-mail Validation
| From: | Jason Murray | Date: | Tue, 12 Dec 2000 04:31:25 +0000 |
| Subject: | RE: [PHP] E-mail Validation | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-29800@lists.php.net to get a copy of this message | ||
> SSorry about all of the questions today,
> But I have made up a discussion page with php and want to put in email
> validation for users posts, can any one help me out on this.
We're using this on INWW:
Function validEmail($emailaddress)
{
// Decides if the email address is valid. Checks syntax and MX records,
// for total smartass value. Returns "valid", "invalid-mx" or
// "invalid-form".
// Validates the email address. I guess it works. *shrug*
if
(eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,3}$",
$emailaddress, $check))
{
if ( getmxrr(substr(strstr($check[0], '@'), 1), $validate_email_temp)
)
{ return "valid"; }
else
{ return "invalid-mx"; }
}
else
{
return "invalid-form";
}
}
This was culled from the notes on PHP's ereg page. There seems to be an
issue
with someone using a '+' sign in his username not passing the test. (Which
means
if anyone can suggest a modification to this eregi to allow a + through in
the
username, it'd be appreciated since I'm quite blonde when it come to this
... :))
Jason
--
Jason Murray
jasonm@melbourneit.com.au
Web Design Team, Melbourne IT
Fetch the comfy chair!