我被这个难住了。非常简单的登录屏幕。当密码匹配时,脚本会完美运行并跳转到 main.php。当 uname 或 pswd 错误时,脚本不会进入 ELSE 子句,也不会转到 badlogin.php。脚本只是挂在空白的白色屏幕上。
任何帮助都会很棒。
<?php
include("dbconnect.php");
$u_name = mysql_real_escape_string($_POST['uname']);
$p_word = mysql_real_escape_string($_POST['pword']);
# *** querying all records ***
$query = mysql_query("SELECT * FROM notes_users WHERE valid_password = '$p_word' && valid_username = '$u_name'");
while($rst = mysql_fetch_array($query)) {
if (($rst[valid_username] == $u_name) AND ($rst[valid_password] == $p_word)) {
session_start();
$_SESSION['login'] = "1";
header('Location: main.php') ;
} else {
session_start();
$_SESSION['login'] = '';
header('Location: badlogin.php') ;
}
}
?>