The function uses regular expressions to validate the format of an email address. If you have questions and suggestions please let me know!
function isValidEmail($email)
{
if(preg_match("/[.+a-zA-Z0-9_-]+@[a-zA-Z0-9-]+.[a-zA-Z]+/", $email) == 0)
return false;
else
return true;
}
Posted 1 month ago #
Very basic email validation. I have a function that also uses regex, but also the getmxrr function that searches dns for MX records corresponding the hostname.
function check_email($email)
{
// Create the syntactical validation regular expression
$match = "^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-0-9-]+)*(\.[a-z]{2,4})$";
// Presume that the email is invalid
$valid = 0;
// Validate the syntax
if (eregi($match, $email))
{
list($username,$domain) = split("@",$email);
// Validate the domain
if (getmxrr($domain,$mxrecords))
$valid = 1;
}
else
{
$valid = 0;
}
return $valid;
}
?>
Posted 1 month ago #
You must log in to post.
.net address attributes browsers censored config css dates email validation filter firefox floor functions html ie ie fix image functions images input ip javascript links mail match math min-height min-width netscape opera php preloading print regex script smtp string styles textbox time validation variables visual basic