We can validate email id with use of regular expression or PHP standard function.
PHP Standard function:
$email = $_POST['email']; if (filter_var($email, FILTER_VALIDATE_EMAIL)) { echo 'This is a valid email.'; } else{ echo 'This is an invalid email.'; }
Regular Expression:
$email = $_POST['email']; if(preg_match("~([a-zA-Z0-9!#$%&'*+-/=?^_`{|}~])@([a-zA-Z0-9-]).([a-zA-Z0-9]{2,4})~",$email)) { echo 'This is a valid email.'; } else{ echo 'This is an invalid email.'; }
you can use above any one of method.