A bit of code that will use reqular expressions to
validate an email address.
URL: http://snippets.dzone.com/posts/show/4022
<?
function validate_email($email){
$exp = "^[a-z\'0-9]+([._-][a-z\'0-9]+)*@([a-z0-9]+([._-][a-z0-9]+))+$";
if(eregi($exp,$email)){
if(checkdnsrr(array_pop(explode("@",$email)),"MX")){
print("$email is ok.
");
}else{
print("$email is ok. But domain is not.
");
}
}else{
print("$email is not ok.
");
}
}
validate_email("shantanu.ok");
validate_email("shantanu.ok@gmail.com");
validate_email("shantanu.ok@fsjaldkfjlsfjsljflsfjsldk.com");
?>
Monday, July 16
Followers
Copyright 2009 mobeamer. Powered by Blogger
Blogger Templates created by Deluxe Templates
Wordpress by Nattywp
2 comments:
function validate_email($email){
$exp = "^[a-z\'0-9]+([._-][a-z\'0-9]+)*@([a-z0-9]+([._-][a-z0-9]+))+$";
if(eregi($exp,$email))
{
if(checkdnsrr(array_pop(explode("@",$email)),"MX"))
{
print("$email is ok.");
}
else
{
print("$email is ok. But domain is not.");
}
}
else
{
print("$email is not ok.");
}
}
validate_email("shantanu.ok");
validate_email("shantanu.ok@gmail.com");
validate_email("shantanu.ok@fsjaldkfjlsfjsljflsfjsldk.com");
I am used this codes. But I got a fatal error. Why this happen?
My error is:
Fatal error: Call to undefined function checkdnsrr()
Plz give me the answer
can you give me the explain below coding.
Why using validate_email?
validate_email("shantanu.ok");
validate_email("shantanu.ok@gmail.com");
validate_email("shantanu.ok@fsjaldkfjlsfjsljflsfjsldk.com");
Post a Comment