Tuesday, May 22, 2012

[php] email validation function

// http://scriptdemo.blogspot.ca
// a simple way to check whether an email address is valid

function CheckEmail($str)
{
   $str=str_replace('#','@',$str);
   if (preg_match("/^[a-zA-Z]+([\._][a-zA-Z0-9]+)*@([a-zA-Z0-9]+\.)+[a-zA-Z]{2,4}$/",$str))
    {
      return TRUE;
    }
   else
    {
      return FALSE;
    }
}
people prefer something from php itself might be interested in filter_var

No comments:

ShowCalendar

  ---- 
      | 
  ---- 
 |      
  ---- 
  ---- 
 |    | 
 |    | 
 |    | 
  ---- 
  ---- 
      | 
  ---- 
 |      
  ---- 
  ---- 
 |      
  ---- 
      | 
  ---- 
        




  ---- 
 |    | 
 |    | 
 |    | 
  ---- 
       
 |    | 
  ---- 
      | 
       
     




       
      | 
      | 
      | 
       
       
 |    | 
  ---- 
      |