The function below valid_email takes in the email address to be validated. In the example below "The email address is invalid." will be displayed on the screen.
<?
function valid_email($address)
{
// check an email address is possibly valid
if (eregi("^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,3})$", $address)){
return true;
} else {
return false;
}
}
$testemailaddress = "abchere.com";
if(valid_email($testemailaddress )){
echo "The email address is valid.";
} else {
echo "The email address is invalid";
}
?>