Monday, October 22, 2012

PHP Function to validate an email address

Here is a simple Function to validate an email address in php.



function check_email($mail_address)
{
                        if($mail_address == '')
                        {
                                    return false;
                        }
                        else
                        {
if (preg_match("/^[0-9a-z]+(([\.\-_])[0-9a-z]+)*@[0-9a-z]+(([\.\-])[0-9a-z-]+)*\.[a-z]{2, 4}$/i",  strtolower($mail_address)))
                                    return true;
                        else
                                    return false;
                        }
}

No comments:

Post a Comment

MS SQL : How to identify fragmentation in your indexes?

Almost all of us know what fragmentation in SQL indexes are and how it can affect the performance. For those who are new Index fragmentation...