Email Validation In PHP

Ever have those annoying spammers sign up for something with their email addy and always make up some donkey crap? Well, here is a script that will allow you to block some of that.

We are going to create this script as a function.

//->Email validation script

function validate_email($email) { 
if (eregi("([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+.[a-zA-Z0-9._-]+)", $email)) return 1; 
else return 0; 
} 
?>

Now time for an example with the function included.

$email = "[email protected]" 
if (validate_email($email)) print "E-mail Address Approved"; 
else print "Nice Try Spammer";

If there are any problems with the script just let me know.

I hope it has been a useful article