我需要你的幫助關於我的代碼在PHP中。我正在製作簡單的登錄表單,但在登錄成功時出現錯誤。當我登錄成功時,我想重定向到另一個網頁。頁面重定向(標題)問題在PHP
瀏覽器錯誤:(請參閱附加圖片) 本地主機頁面不工作 localhost重定向您太多次了。 嘗試清除您的Cookie。 ERR_TOO_MANY_REDIRECTS
<?php
$errors = array();
if(isset($_POST['submit'])) {
$username = trim($_POST["username"]);
$password = trim($_POST["password"]);
if(!isset($username) || empty($username) || !isset($password) || empty($password)) {
$errors['$blank'] = "Fields can't be blank.";
}
else {
$errors = "";
}
$min = 6;
if(strlen($username) < $min || strlen($password) < $min) {
$errors['$minAllowed'] = "Only minimum of 6 characters is allowed";
}
$max = 12;
if(strlen($username) > $max || strlen($password) > $max) {
$errors['$minAllowed'] = "Only maximum of 12 characters is allowed";
}
}
function form_errors($errors=array()) {
$output = "";
if(!empty($errors)) {
$output = "<div class=\"error\">";
$output .= "Please fix the following errors:";
$output .= "<ul>";
foreach ($errors as $key => $error) {
$output .= "<li>{$error}</li>";
}
$output .= "</ul>";
$output .= "</div>";
}
else {
header("Location: " . "p1.php");
}
return $output;
}
?>
什麼是'標題的意思( 「位置:」 「p1.php」);'? – Nawin
檢查您的標題位置線的其他語句 – Akintunde007
'header(「Location:」。「p1.php」);'應該是'header(「Location:p1.php」);' –