0

Validate email address using PHP

You need to validate email addresses when you create contact forms and other kinds of forms when you need get users email address.

Its simple, this is how to validate and email address using PHP code.

Normal way

$email = "mahmud@thinkdiff.net";
if(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) {
  echo "Valid email address.";
}
else {
  echo "Invalid email address.";
}

This is how to do that using PHP filter function.

$email  = "mahmud@thinkdiff.net";
 
 if(filter_var($email, FILTER_VALIDATE_EMAIL)){
      echo " $email is valid email address <br />";
 }elseif(filter_var($email, FILTER_VALIDATE_EMAIL) === FALSE){
      echo " $email is not a valid email address <br />";
 }

– 300 views

Related Posts Plugin for WordPress, Blogger...


Subscribe to KathaBuzz via email now:

Delivered by FeedBurner

Filed in: Code, How to Tags: , , , ,

Get Updates

Share This Post

Related Posts

Leave a Reply

Submit Comment

© 2013 .::KathaBuzz::.. All rights reserved.
Read previous post:
innOS
innOS D9 MSM8225 vs innOS I5 MSM7227A (Dialog i43)

This is just a comparison of most potential Android Smartphones by innOS. You can see our individual reviews at the...

SETT Sinhala Tamil web Browser
How to get Sinhala & Tamil fonts on your Android Smartphones

One of the most common question that  I get asked is how to get Sinhala fonts displayed on Android phones,...

Dr. Abdul Halam : You cannot change your FUTURE, you can change your HABITS. And surely your HABITS will change your FUTURE
Dr. Abdul Kalam : You cannot change your FUTURE, you can change your HABITS. And surely your HABITS will change your FUTURE

    You cannot change your FUTURE, you can change your HABITS. And surely your HABITS will change your FUTURE...

Lou Holtz : Life is ten percent what happens to you and ninety percent how you respond to it
Lou Holtz : Life is ten percent what happens to you and ninety percent how you respond to it

    Life is ten percent what happens to you and ninety percent how you respond to it

Close
Read more Code articles here