<?php include_once 'connect.inc.php'; error_reporting(0); if($_GET['login'] == 'out'){ setcookie("cookie","out"); echo "<script language=\"javascript\">location.href='login.php'</script>"; } if($_POST['submit']){ $pw = md5($_POST['password']); $sql = "SELECT * FROM member WHERE `username`='".$_POST['password']."';"; $result = mysql_query($sql, $conn); $num = mysql_num_rows($result); if($num) //判断是否有这个用户 { $arr = mysql_fetch_array($result); if($arr['password'] == $pw) //判断密码是否正确 { setcookie("cookie","ok"); echo "<script language=\"javascript\">alert('登陆成功!');location.href='login.php'</script>"; }else { echo "<script language=\"javascript\">alert('密码错误!');</script>"; } }else { echo "<script language=\"javascript\">alert('没有这个用户!');</script>"; } } include_once 'head.inc.php'; if($_COOKIE['cookie'] != "ok"){?><script language="javascript"> function CheckLogin(){ if(login.user.value == ""){ alert("用户名不能为空!"); myform.user.focus(); return false; } if(myform.password.value == ""){ alert("密码不能为空!"); myform.password.focus(); return false; } }</script><form name="login" method="post" onsubmit="return CheckLogin();"> 用户名:<input type="text" name="user"><br /> 密 码:<input type="password" name="password"><br /> <input type="submit" name="submit" value="登陆"></form><?php }else{ echo "<a href=\"login.php?login=out\">退出</a>"; }?>
用户正确,密码不正确时是弹出没有这个用户对话框,逻辑关系我也看了多遍,感觉没有问题。求解,是什么原因???
ITMISS
30秒到达战场
相关分类