第一行出錯未定義索引:$ pwd 還有未定義的變量在它下面。 請顯示新的代碼謝謝! 它的結尾吐出來。PHP未定義索引/變量
$pwd = $_POST['$pwd']; //Error undefined index: $pwd
if(strlen($pwd) < 8) {
$error .= "Password too short!
";
} //This line undefined variable
獲取上述錯誤在這裏******錯誤變量
if(strlen($pwd) > 20) {
$error .= "Password too long!
";
}
if(strlen($pwd) < 8) {
$error .= "Password too short!
";
}
if(!preg_match("#[0-9]+#", $pwd)) {
$error .= "Password must include at least one number!
";
}
if(!preg_match("#[a-z]+#", $pwd)) {
$error .= "Password must include at least one letter!
";
}
if(!preg_match("#[A-Z]+#", $pwd)) {
$error .= "Password must include at least one CAPS!
";
}
if(!preg_match("#\W+#", $pwd)) {
$error .= "Password must include at least one symbol!
";
}
if($error){
echo "Password validation failure(your choice is weak): $error";
} else {
echo "Your password is strong.";
}
再次感謝:d
你真的有一個名稱爲「$ pwd」,美元符號和全部的元素嗎? – adeneo 2015-02-24 10:59:26
也許'$ pwd = $ _POST ['pwd'];'? – lmarcelocc 2015-02-24 11:00:03
(與問題無關:)此外,您可能會考慮在字符串的末尾使用「\ n」(添加換行符),而不是真正以換行符結尾。 – matthias 2015-02-24 11:39:56