Re: eregi problems
| From: | Miguel Cruz | Date: | Fri, 05 Jul 2002 07:01:51 +0000 |
| Subject: | Re: eregi problems | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-105577@lists.php.net to get a copy of this message | ||
On Thu, 4 Jul 2002, dan radom wrote:
> I've got a form that's posted to a php page where I'm attempting to validate a
> field contains a valid email address. The eregi below seems to be totally ignored...
>
> if (eregi("^[a-z0-9\._-]+@[a-z0-9\._-]+$", $emp_email)) {
> echo "<center>please enter a valid email address</center>";
> exit;
> }
>
> $emp_email is being posted to the form. Any ideas why this is being ignored?
Wow, I would be annoyed if I used your site, as it rules out perfectly
valid email addresses of a format I'd be likely to provide to a web site.
Clue 1: Far more characters are valid before the @ sign.
Clue 2: The underscore (_) is not valid after the @ sign.
Why randomly make up guesses about what a valid email address might be?
RFC 822 is no secret, and there are secondary references under every
virtual rock.
As for your ereg problem itself, it's returning true on a so-called valid
address, so you'd be getting the opposite results of what you expect.
Switch your if around or add a ! before the eregi call.
miguel