How to Validate email address with PHP

email-validate-1Often when building applications you need to take care of security specailly when user generated content apps. Spam is our common enemy. To eradicate spam certain filters need to be implemented.

Email validation is one of them. Email validation can stop much of your spam content. Before we get started I would like to tell you that this is much simple funcion that only checks if your email is in proper format i.e email@domain.com. I won’t recommend you to use the same for your applications.

The below function will return false incase the email is not correct and returns the email address if the email address format is correct. Original idea by Regan Johnson

function verify_email($email){
    if(!preg_match('/^[_A-z0-9-]+((.|+)[_A-z0-9-]+)*@[A-z0-9-]+(.[A-z0-9-]+)*(.[A-z]{2,4})$/',$email)){
        return false;
    } else {
        return $email;
    }
}

Related posts:

  1. How to Control A PHP Web Application Remotely
  2. How to remind your visitors to stumble you
  3. 10 Simple ways to protect and secure your PC from Internet Threats
  4. Welcome to MyGeekPal
  5. [Video] How To Uninstall Applications in Windows XP


The author is a small business owner himself specialising in Web Development. He runs Insight Studios which offers specialized Web Development, SEO Services and PPC Management for Small Business and SME thus ensuring growth and prosperity using the power of social media.

Share This Post

Related Articles

Leave a Reply

© 2012 MyGeekPal. All rights reserved. Site Admin · Entries RSS · Comments RSS
Designed by Insight Studios