所以我有一個用戶名和密碼形式發佈數據到這個process.php文件。但是,我的代碼中的陷阱錯誤提示mysql查詢出了問題:「用戶名和密碼不匹配,我們會在兩秒內將您帶回登錄頁面。」PHP的幫助,不知道爲什麼這不起作用
md5工作正常,我檢查了數據庫表中的所有行都在那裏以及它應該如何。有什麼建議麼?謝謝戴夫。
<?php
//Code DavidMaitland.me 2011
//Process data from the login form
require('database.php');
$username = mysql_real_escape_string($_POST["username"]);
$password = mysql_real_escape_string(md5($_POST["password"]));
$client_query = mysql_query("SELECT * FROM clients WHERE client_username='$username' and client_password='$password'") or die (mysql_error());
$client_data = mysql_fetch_array($client_query, MYSQL_ASSOC);
if(mysql_num_rows($client_data) == 1) {
session_start();
$_SESSION['client_id'] = $client_data['id'];
header('Location: account.php');
} else {
echo "The username and password don't match. We will take you back to the login page in two seconds.";
header('Refresh: 2; url=index.php');
}
?>