douhuan1979 2010-06-07 18:44 采纳率: 100%
浏览 19
已采纳

我的PHP登录不再有效

This page worked like a charm for years... enter the correspondng user id and password and you would be redirected to your directory. Now suddenly, all attempts to log in - valid or otherwise - result in the page remaining static... no message, no redirect, nothing.

Nothing in the code has changed, it just plain doesn't work anymore. Could this be the result of some kind of change on the server side?

Yeah, I know it's not super secure, but it was good enough for our purposes. I'm certainly open to better suggestions. I just need it to work... and keep working.

Please be gentle! I know almost nothing of programming.

Here is the page code:

<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>
";

if ($pass[$userIndex] == $password)
{
$authenicated = true;
$link = "/incoming/clients050203/" . $directory[$userIndex] . "/";
$message = $message . "Password Valid - Redirecting to your folder...<br>
";
}
else
{
$message = $message . "Incorrect Password<br>
";
}
}
else
{
$message = $message . "Incorrect User Name<br>
";
}

}
?>




<?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>
  • 写回答

4条回答 默认 最新

  • dpowhyh70416 2010-06-07 18:49
    关注

    It looks like you're depending on global variables being initialized, rather than using them correctly. You use $username and $password without initializing them. The correct way would be to do:

    $username = $_POST['username']; $password = $_POST['password'];

    Before you use them. This would be a result in them updating stuff on the server side.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 路易威登官网 里边的参数逆向
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决
  • ¥15 processing提取音乐节奏
  • ¥15 gg加速器加速游戏时,提示不是x86架构
  • ¥15 python按要求编写程序
  • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入