-1

My code is not running properly. What am I doing wrong? Please suggest. Here is the code:

 elseif(!preg_match("/^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$/i", $email))  
 {   $errorMsg= "error: You did not enter a valid email.";   $code= "3";   }
Anks
  • 7
  • 5

1 Answers1

0

Please use data validation filters available in PHP.

http://php.net/manual/en/filter.filters.validate.php

example.

if (filter_var($email, FILTER_VALIDATE_EMAIL) === false) {
  echo("please enter a valid email address");
}
Pramod Sivadas
  • 873
  • 2
  • 9
  • 28