Hi,
I'm currently writing a script.. and in that script they have to supply an email etc.. and am looking for a way to validate the email. I was wondering if I used something like below... if it would work.
(This is my first time doing anything with validating an email etc, so please be kind, lol)
If I'm doing something wrong, or If I'm doing something right.. let me know either way. Thanks!
-Eric
I'm currently writing a script.. and in that script they have to supply an email etc.. and am looking for a way to validate the email. I was wondering if I used something like below... if it would work.
(This is my first time doing anything with validating an email etc, so please be kind, lol)
PHP:
$em = eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email);
if ($em != eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email))
{
echo 'Sorry, you entered an invalid email address.';
} else {
$email = $em;
//Rest of script
}
If I'm doing something wrong, or If I'm doing something right.. let me know either way. Thanks!
-Eric





