在过去的四天里,我一直在努力让这个工作。这只是一个简单的登录页面,其中没有存储敏感信息,但我遇到了 PHP 问题。
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$uname = $_POST["login"];
$pword = $_POST["pass"];
$uname = htmlspecialchars($uname);
$pword = htmlspecialchars($pword);
$user_name = "bradf294_access";
$password = "********";
$database = "bradf294_clients";
$server = "localhost";
$db_handle = mysql_connect($server, $user_name, $password);
$db_found = mysql_select_db($database, $db_handle);
print(mysql_errno());
print($db_found);
if(isset($db_found)){
print($db_found."Success");
$SQL = "SELECT * FROM basicinfo WHERE ref = $uname AND pass = $pword";
$result = mysql_query($SQL);
print("Query made");
print(mysql_errno());
if ($result) {
print("result:".$result);
}
else {
print("Incorrect Login Details");
}
if ($result > 0) {
print("found user");
$errorMessage= "logged on ";
session_start();
$_SESSION['login'] = "1";
header ("Location: progressuser.php");
}
else {
print("Invalid Logon");
}
} else {
print("Database not found. The Webmaster has been notified. Please try again later");
$subject = "Automated login error" ;
$message = "An error occured whilst trying to connect to the MySQL database, to login to the progress checker" ;
mail("a-bradfield@bradfieldandbentley.co.uk", $subject, $message);
}
从我一直用来调试的页面上的输出来看,它似乎是那些似乎不起作用的行,它们给出了 1054 错误 - “'%s' 中的未知列 '%s'”
$SQL = "SELECT * FROM basicinfo WHERE ref = $uname AND pass = $pword";
$result = mysql_query($SQL)
即使我将$SQL
字符串复制并粘贴到 phpMyAdmin 中并且效果很好?
有什么明显的我做错了吗?转到http://www.bradfieldandbentley.co.uk/test/progress.php并输入详细信息 Reference:TST001
并通过:dnatbtr121
自己查看输出。