问题是如果您$_POST['username']
包含数据库中存在的用户名,则脚本运行良好。如果用户名输入错误,或者除了在数据库中找到的内容之外还输入了其他任何内容,它就会被锁定。
有没有办法构造SELECT
一个“else”类型的语句,当发生拼写错误时它会“这样做”......
提前致谢
include('includes/config.php');
if($_REQUEST['do'] == 'login') {
$postusername = $_POST['username'];
$result = mysqli_query($con,"SELECT * FROM $sqlusers WHERE
username = '$postusername'");
while($row = mysqli_fetch_array($result))
{
if($_POST['username'] == $row['username'] &&
$_POST['password'] == $row['password']){
$logged_username = $row['username'];
$_SESSION['username']= $logged_username;
$_SESSION['active']=1;
session_write_close;
//to redirect back to "index.php" after logging out`
header("location:/index.php");
}
else {
header("Location:login.php?errorMssg=".urlencode("Your Login
Information is incorrect!!"));
}
}
}