所以我有一个用户名和密码形式发布数据到这个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');
}
?>