So basiclly i just want this code below:
//basic email validation
if(!eregi('^x[\d]{8}@student\.ncirl\.ie$', $email)){
// Return Error - Invalid Email
$error = true;
$emailError = 'The email you have entered is invalid, please try again.';
}
if ( !filter_var($email,FILTER_VALIDATE_EMAIL) ) {
$error = true;
$emailError = "Please enter valid email address.";
} else {
// check email exist or not
$query = "SELECT userEmail FROM users WHERE userEmail='$email'";
$result = mysql_query($query);
$count = mysql_num_rows($result);
if($count!=0){
$error = true;
$emailError = "Provided Email is already in use.";
}
}
To validate the email if it is exactly similar to email - "x14332684@student.ncirl.ie" , i want it to keep the x at the start, have 8 random numbers after x and as it is everything after @. Only numbers to be random and the rest should be a "must". I just cant get it to validate the email like i want, using this code tells me pernament "The email you have entered is invalid, please try again.". Can anyone edit the code for me and point out what am i doing wrong in it? Thank you.
This works with preg_match. One thing you need to do is wrap the pattern with delimiters, most use /
like:
if(!preg_match('/^x[\d]{8}@student\.ncirl\.ie$/', $email)){
// Return Error - Invalid Email
$error = true;
$emailError = 'The email you have entered is invalid, please try again.';
}
使用此站点: http : //www.phpliveregex.com/以获取将来的preg_matche
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.