My if elseif statements are being triggered every time I hit submit and it is only specific ones. I have checked Stack for similar problems but they all have to do with statements not triggering. I have also tried to validate my form multiple times and no matter what, right or wrong, these specific ones are triggered:
Username: strlen statement
Password: strlen statement
E-Mail: FILTER_VALIDATE_EMAIL
Empty Check is triggered even with all fields filled
Any help with correcting this would really be appreciated.
//Spam Check
if($spam > 2){
$error .= '<div class="problem">Too many accounts have been created from this IP Address. Please contact us if you would like to create more.</div>';
}
//Username Check
if(!preg_match("/^[a-zA-Z0-9 ]*$/",$user)){
$error .= '<div class="problem">You may only use letters and numbers in your username.</div>';
}
elseif(strlen($user) < 3 OR strlen($user) > 20){
$error .= '<div class="problem">Please use an username between 3 and 20 characters.</div>';
}
elseif($taken > 0){
$error .= '<div class="problem">This username has already been taken. Please choose another.</div>';
}
//Password Check
if(!preg_match("/^[a-zA-Z0-9 ]*$/",$pass1)){
$error .= '<div class="problem">Do not use special characters in your password.</div>';
}
elseif(strlen($pass1) < 5 OR strlen($pass1) > 20){
$error .= '<div class="problem">Your password must be at least 5 characters and no more than 20.</div>';
}
elseif($pass1 != $pass2){
$error .= '<div class="problem">You did not confirm your passwords correctly. Please make sure they are the same.</div>';
}
//E-Mail Check
if(!filter_var($email, FILTER_VALIDATE_EMAIL)){
$error .= '<div class="problem">The E-Mail Address entered was invalid. Please use another.</div>';
}
elseif(strlen($email) > 50){
$error .= '<div class="problem">This E-Mail Address is too large for us to store. Please use a different one.</div>';
}
//Empty Check
if(empty($user) OR empty($pass1) OR empty($pass2) OR empty($email)){
$error .= '<div class="problem">You need to fill out all fields to create an account.</div>';
}
Aucun commentaire:
Enregistrer un commentaire