Re: Re: How do I validate input using php?
| From: | Miguel Cruz | Date: | Thu, 25 Jul 2002 07:43:49 +0000 |
| Subject: | Re: Re: How do I validate input using php? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-109437@lists.php.net to get a copy of this message | ||
On Wed, 24 Jul 2002, Mike Mannakee wrote:
> Here's the code I use to validate emails:
>
> function check_email($email)
> {
> global $email;
> $regex="^([a-z0-9_]|\\-|\\.)+@(([a-z0-9_]|\\-)+\\.)+[a-z]{2,4}$";
> return eregi($regex, $email, $trash);
> }
Please search the archives on this topic; it's been covered exhaustively,
and each time it comes up we get 25 bad functions and eventually one good
one. The above function will bark at valid domains (.museum, etc.) and
will allow patently invalid domains (anything containing _).
miguel