有如下两个php文件:
loginProcess.php
<?php
//echo print_r($_POST);
$admin_id =  $_POST['admin_id'];
$pasw = $_POST['password'];

$conn = mysql_connect("localhost","root","root");

if(!$conn) {
die("连接失败".mysql_error());
}

mysql_query("set names utf8");

mysql_select_db("test",$conn);

$sql = "select password form admin where admin_id = $admin_id";

$res = mysql_query($sql,$conn);


if($row=mysql_fetch_assoc($res)) {

if($row['password']==md5($pasw)) {
header("Location:empMnanage.php");
eixt();
}else {
header("Location:login.php?erorr=1");
exit();
}
}

mysql_free_result($res);
mysql_close($conn);
?>
login.php<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<h1>管理员登录系统</h1>
<form action="loginProcess.php" method="post">

<table>
<tr>
<td>用户id</td>
<td><input type="text" name="admin_id"/></td>
</tr>
<tr>
<td>密&nbsp;&nbsp;码</td>
<td><input type="text" name="password"/></td>
</tr>
<tr>
<td><input type="submit" value="用户登录"></td>
<td><input type="reset" value="重新填写"/></td>
</tr> </table>

</form>

<?php 
    
if(!empty($_GET['erorr'])){

$erroNum = $_GET['erorr'];

if($erroNum==1) {
echo "<font color='red'>用户名有误,请重新输入!</font>";
}
}
?>


</body>
</html>
请问,用login.php提交到处理页面loginProcess.php,用zendStdio怎么没办法debug。还有,处理页面loginProcess.php有什么问题吗?

解决方案 »

  1.   

    $sql = "select password form admin where admin_id = $admin_id"; 这句
    from 不是form。 再没发现什么错
      

  2.   

    ZendStudio Debug要配置一下。
    PHP是远程调试,你要找下相关配置文档。
    要注意端口号。默认调试端口号可能有冲突,这是我安装的经验。
    ----------------------------------------------
    另外你代码登录成功后要创建Session。否则很容易被非法登录。
      

  3.   

    是否是error=1 ?,写代码要细心,注意标记提示。
    1#正解。