那是代码
<?php
//Start session
session_start();
//Then we retrieve the posted values for user and password.
$username = $_POST['username'];
$password = $_POST['password'];
//Users defined in a SQLite database
$db = new PDO("sqlite:/www/test.db");
$result = $db->query("SELECT COUNT(*) FROM users WHERE Username = '$username' AND Password = '$password'");
if ($result > 0)
{
//If user and pass match any of the defined users
$_SESSION['loggedin'] = true;
// close the database connection
unset($db);
header("Location: index.php");
};
//If the session variable is not true, exit to exit page.
if(!$_SESSION['loggedin'])
{
// close the database connection
unset($db);
header("Location: login.html");
exit;
};
?>
数据库架构:
用户名 TEXT NOT NULL PRIMARY KEY UNIQUE,密码 TEXT
唯一的行数 Username='admin' 和 Password='admin'
任何想法为什么脚本每次都会将我重定向到 index.php,即使用户名和密码不在数据库中?
提前致谢