Thursday, July 19, 2012

Email validation using Regular Expression

Following code shows how to validate email in php.

<?php // chek email validation
if (!preg_match('/^[^0-9][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[@][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[.][a-zA-Z]{2,4}$/',$_POST['email']))
{
echo "invalid Email Address";
}
?>

1 comment:

Ishika Khanna said...

Seems to be a perfect place to learn something new.. Here I can pick many things for my blog as I have recently created and its in progress. My blog is totally different from your blog. But still I want the admin to suggest me that how can I attract visitors to increase traffic. Have a look here, http://free-songs.org on my blog and do suggest me if there is any requirement for any change. I would be really glad and any suggestions would be appreciated. Thanks in advance!!!!