I'm making now registration for my site. I have made validation.php file in which i have all functions that are validating my data. Email is validated like this:
if (filter_var($string, FILTER_VALIDATE_EMAIL) == false) {
$allChecked = false;
$_SESSION['emailError'] = "Your email has to be valid.";
}
But when i click on button (in registration form) when email is invalid (random letters) is gets through validation like the email is okay. So how i have to this so the email gets properly validated. Thanks for every answer
Try this code below.
It will allow good email but will prevent in valid email
$email= 'nancy@gmai'; // bad email
/*
$email= 'nancy@gmail.com'; //good email
*/
$em= filter_var($email, FILTER_VALIDATE_EMAIL);
if (!$em){
echo "Email Address is Invalid";
//$_SESSION['emailError'] = "Your email has to be valid.";
exit();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.