多年来,这个页面就像一个魅力...输入相应的用户 ID 和密码,您将被重定向到您的目录。现在突然之间,所有登录尝试(无论是否有效)都会导致页面保持静态……没有消息,没有重定向,什么都没有。
代码中没有任何变化,它只是不再起作用了。这可能是服务器端某种更改的结果吗?
是的,我知道它不是 super 安全,但对于我们的目的来说已经足够好了。我当然愿意接受更好的建议。我只需要它工作……并继续工作。
请温柔一点!我对编程几乎一无所知。
页面代码如下:
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
<link href="ilium.css" rel="stylesheet" media="screen">
<title>Ilium: Client Login</title>
</head>
<body bgcolor="#bfbfcc" background="img/loginbg.gif">
<?php
/* init vars */
$userExists = false;
$userIndex = -1;
$authenicated = false;
/***********************************************
* edit this to add new users/password *
* - add user/pass/directory to the array *
* below: must be in same array index to work *
***********************************************/
$user = array('foo', 'bar');
$pass = array('foo', 'bar');
$directory = array('foo', 'bar');
// run user/pass check if data passed
if (isset($username) && isset($password))
{
// check if user name exists
for ($i = 0; $i < count($user); $i++)
{
if ($user[$i] == $username)
{
$userExists = true;
$userIndex = $i;
break;
}
}
// so user exists, now test password
if ($userExists)
{
$message = $message . "Username Valid<br>\n";
if ($pass[$userIndex] == $password)
{
$authenicated = true;
$link = "/incoming/clients050203/" . $directory[$userIndex] . "/";
$message = $message . "Password Valid - Redirecting to your folder...<br>\n";
}
else
{
$message = $message . "Incorrect Password<br>\n";
}
}
else
{
$message = $message . "Incorrect User Name<br>\n";
}
}
?>
<?php
// user has been authenicated - move them to the correct directory
if ($authenicated)
{
echo "<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=" . $link . "\">";
}
?>
<img src="img/spacer.gif" alt="" width="1" height="112" border="0">
<form action="login.php" method="post">
<table width="496">
<tr>
<td width="100"></td>
<td colspan="4" width="469"><img src="img/please.gif" alt="" width="469" height="19" border="0"></td>
</tr>
<tr>
<td width="100"><img src="img/spacer.gif" alt="" width="100" height="1" border="0"></td>
<td width="227">
<img src="img/spacer.gif" alt="" width="227" height="1" border="0"><br>
</td>
<td align="right" valign="top" width="84"><input type="text" name="username" size="12"><br></td>
<td width="43"><img src="img/spacer.gif" alt="" width="43" height="1" border="0"><br>
<br>
</td>
<td align="right" valign="top" width="109"><input type="password" name="password" size="16">
<p><br>
</p>
</td>
</tr>
<tr>
<td width="100"></td>
<td valign="top" width="227"><div class="messages"><?=$message?></div></td>
<td width="84"><br>
</td>
<td width="43"><br>
</td>
<td align="right" width="109"><input type="image" src="img/enter.gif" ALT="enter"><br>
<br>
<br>
<br>
<br>
</td>
</tr>
</table>
</form>
</body>
</html>
最佳答案
据我所知,您的代码依赖于已弃用多年的 register_globals。您的服务器可能已升级到较新版本的 php。
使用 register_globals 真的很糟糕,不是“你不应该”那种糟糕,而是“使用它太疯狂了”。请不要试图寻找解决方法。使用 $_GET 和 $_POST 参数来实现您的目标。
关于php - 我的 PHP 登录不再有效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2992173/