Anks February 2016

Email Validation on user registration form

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";   }

Answers


Pramod Sivadas February 2016

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");
}

Post Status

Asked in February 2016
Viewed 2,203 times
Voted 10
Answered 1 times

Search




Leave an answer