我在用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