Re: How do I validate input using php?
| From: | Mike Mannakee | Date: | Thu, 25 Jul 2002 02:11:41 +0000 |
| Subject: | Re: How do I validate input using php? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-109402@lists.php.net to get a copy of this message | ||
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);
}
Hope this helps,
Mike
"ØYstein HåLand" <molen@mbox302.swipnet.se> wrote in message
news:20020724224014.62119.qmail@pb1.pair.com...
> I've tried a function like this:
> function validate() { //
> if ( is_numeric($input1) && is_numeric($input2) && ctype_alpha($input3)
> &&
> ctype_alpha($input4) )
> return true;
> }
>
>
> And then I call the function:
>
> if (validate() == false) {
> some action;
> }
>
> My problem is I get the action every time, even though the input is of the
> right type. And, is ctype_alpha() the only way to check for only
alphabetic
> characters?
> And (this started with one question), anyone got a good solution on
> validating email-adresses with php?
>
>