我有一个登录表单,当我进入该页面时,它会自动给我警报消息。我还没有输入用户名和密码信息。
这是验证登录表单输入的页面,请看看为什么会这样?
<?
session_start();
include "config.php";
if(isset($_SESSION["login_user"]) AND isset($_SESSION['pass_user'])){
$login_user = $_SESSION["login_user"];
$pass_user = $_SESSION["pass_user"];
$sql = mysql_query("SELECT * FROM adm WHERE login = '$login_user'");
$cont = mysql_num_rows($sql);
while($linha = mysql_fetch_array($sql)){
$pass_db = $linha['pass'];
}
if($cont == 0){
unset($_SESSION["login_user"]);
unset($_SESSION["pass_user"]);
echo "
<META HTTP-EQUIV=REFRESH CONTENT='0; URL=login.php'>
<script type=\"text/javascript\">
alert(\"Name of user dont match.\");
</script>";
}
if($pass_db != $pass_user){//check pass
unset($_SESSION["login_user"]);
unset($_SESSION["pass_user"]);
echo "
<META HTTP-EQUIV=REFRESH CONTENT='0; URL=login.php'>
<script type=\"text/javascript\">
alert(\"Password dont match.\");
</script>";
}
}else{
echo "
<META HTTP-EQUIV=REFRESH CONTENT='0; URL=login.php'>
<script type=\"text/javascript\">
alert(\"User and password dont match.\");
</script>";
}
?>