无法理解这里发生了什么。代码中的注释解释。提前致谢。为了更容易阅读,缺少一些代码位,例如写入 DB 部分。但问题与这些线路无关。
if (filter_var($email, FILTER_VALIDATE_EMAIL) == TRUE and
preg_match("/^[\w ]+$/", $address_one) == TRUE and
preg_match("((?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%]).{8,20})", $password) == TRUE) {
//When given a valid email/address/password the code successfully gets to this point and inserts into a DB
} else {
//When it fails validation with an invalid email/password/address it drops in here
//but then it doesn't change error code variable...
$errorcode = "IHAVENOTCHANGED";
if (filter_var($email, FILTER_VALIDATE_EMAIL) == FALSE) {
$errcode = " email,";
}
if (preg_match("/^[\w ]+$/", $address_one) == FALSE) {
$errcode = " address line 1,";
}
if (preg_match("((?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%]).{8,20})", $password) == FALSE) {
$errcode = " password,";
}
writetolog("LoginCreation", "Login failed due to invalid input: " . $errorcode . " - user: " . $email);
echo "Invalid data for $errorcode please try again -- ADDRESS=$address_one -- EMAIL=$email -- PASS=$password";
}