Home  »     »     »  PHP function to check valid Email Addresses

PHP function to check valid Email Addresses

Thursday, December 2, 2010


Here is a Simple PHP function to check valid Email Addresses.

The function accepts Email string
trims it

check whether it satisfies the Email format.

if it satisfies then return TRUE else FALSE.


Scroll down for the function.




function validateEmail( $strEmail ){

$strEmail=trim($strEmail);
if( $strEmail!="" ){
$pattern="/^([a-z0-9_\.]+)@([a-z0-9_\-\.]+)\.([a-z]{2,3})$/i";
if( preg_match($pattern,$strEmail,$match) ){
return TRUE;
}else FALSE;
}else
return TRUE;

}




How to use this function?


$myEmail=$_POST['txt_email'];

if validateEmail( $myEmail )
echo("VALID EMAIL");
else
echo("YOU ENTERED AN INVALID EMAIL.");






Hope thi shelp someone... :)



How to link to this page?
If you wish to link to this page from your website, simply Copy and paste the above HTML code to your web page. It will appear on your page as:
PHP function to check valid Email Addresses.




Share this!




comments powered by Disqus

This Weeks 7 Popular Posts


Subscribe to Recent Posts by Email
Stay connected to CROZOOM with regular Email notices of new Techie articles and IT Jobs. Updates will be delivered to your Inbox as soon as they are posted online.

Enter Your Email Address:  

Delivered by FeedBurner   RSS Feed

Search this Blog   



Urgent Openings for PHP trainees, Andriod / IOS developers and PHP developers in Kochi Trivandrum Calicut and Bangalore. Please Send Your updated resumes to recruit.vo@gmail.com   Read more »