我在用PHP代碼查找密碼保護我的網站(index.html)上的特定頁面。只保護一頁的密碼
這就是我現在所擁有的(此代碼是從另一個問題就在這裏C/P):
<?php
session_start();
$username="admin";
$password="jATPqhu9";
if(isset($_POST['username']) && $_POST['username'] == $username && $_POST['password'] == $password)
{
header("Location: ecks.html");
exit;
}
else
{
?>
<html>
<head>
</head>
<body>
<div style='text-align:center'>
<h3>Welcome To ---</h3>
</div>
<hr /><br />
<form id='login' action="" method='post' accept-charset='UTF-8'>
<fieldset style="width:550px">
<legend>Admin Login</legend>
<input type='hidden' name='submitted' id='submitted' value='1'/>
<label for='username' >UserName:</label>
<input type='text' name='username' id='username' maxlength="50" />
<label for='password' >Password:</label>
<input type='password' name='password' id='password' maxlength="50" />
<input type='submit' name='submit' value='Submit' />
</fieldset>
</form>
</body>
</html>
<?php
}
?>
出於某種原因,重定向的部分(標題( 「位置:ecks.html」); )不會重定向到ecks.html。
是的。除了重定向之外,一切都有效。 –
檢查你的http服務器錯誤日誌文件,很可能是在調用head函數的輸出_before_中。 – arkascha
另外看看你的瀏覽器控制檯網絡選項卡應該顯示是否根本發送了這個頭文件。 – arkascha