Re: how to catch invalid email in form
From: Ian.H (ian_at_WINDOZEdigiserv.net)
Date: 03/29/04
- Next message: Markus Ernst: "Re: goto in php"
- Previous message: Damian John Paul Brown: "FAO: Warren from Canada"
- In reply to: jn: "Re: how to catch invalid email in form"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 29 Mar 2004 07:58:09 GMT
On Mon, 29 Mar 2004 01:37:43 +0000, jn wrote:
> "Danny" <dannywork5@hotmail.com> wrote in message
> news:50K9c.138016$LX.14794284@news4.srv.hcvlny.cv.net...
>> I tried to look on google but did not find a method of testing a string to
>> make sure it is in form
>> asdf@something.something
>>
>> Can you give me a hint?
>>
>> Thanks again
>>
>>
>>
>
> An old Javascript function I found on Google (this is a common question,
> Google is your friend)
And this is a pointless solution as is the last poster's. DO NOT rely on
Javascript for validation. It can be used as a "speed enhancement" but
NEVER rely solely on it. Both your solution and the previous poster's
solution would have exactly zero affect if I visited your site(s) as
Javascript is disabled in my browser.
Although not perfect I'm sure.. a serverside, PHP function that appears to
work for myself anyway...
function check_email($addy, $return_mx_records = false) {
if (empty($addy)) return false;
if (!preg_match(
'/^[a-zA-Z0-9&\'\.\-_\+]+\@[a-zA-Z0-9.-]+\.+[a-zA-Z]{2,6}$/',
$addy)
) {
return false;
}
$mx_exists = false;
if (getmxrr(array_pop(explode('@', $addy)), $mx_records)) {
$mx_exists = true;
}
if ($mx_exists) {
return ($return_mx_records) ? $mx_records : true;
} else {
return false;
}
}
Regards,
Ian
-- Ian.H digiServ Network London, UK http://digiserv.net/
- Next message: Markus Ernst: "Re: goto in php"
- Previous message: Damian John Paul Brown: "FAO: Warren from Canada"
- In reply to: jn: "Re: how to catch invalid email in form"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|