unable to validate email address in php

cute.bandar

Cyborg Agent
This should work, but I just can't figure out what wrong here. HOping that there is something simple I am missing

Code:
function email_valid ($email) 
        {  
          if (preg_match("/^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$/i", $email)) 
                        return true;
          else  return false;
          
        }
if ( email_valid($email)  == FALSE ) ;
{
      $errors[] = "notemail" ;
}
In this email_valid always returns false , no matter what the parameter is.
What is wrong here. Every email address supplied is treated as invalid.
Help!
 

khmadhu

change is constant!!
u have a typo here..
if ( email_valid($email) == FALSE ) ;

why there is a semicolon at the end of if statement!! ?

remove that it will work.. :)

and a tip for u..
and in regex if u r giving /i at the end u dont need to specify A-Z
 
Top Bottom