這是代碼!當數據已經在數據庫中時,PHP沒有從數據庫獲取用戶數據!幫助我,我卡住了。當我在login.php中輸入詳細信息時,它會將我重定向到login.php?invalid = 1,並顯示錯誤信息或會話過期錯誤!儘管信息是一樣的!當數據已經在數據庫中時,PHP沒有從數據庫中獲取用戶數據
<?php
session_start();
include_once("include\config.php");
$login = $_POST["textfield1"];
$pwd = $_POST["textfield2"];
$recordset = mysql_query("select * from users");
while($record = mysql_fetch_array($recordset)){
if($login == $record["ulogin"] && $pwd == $record["upassword"]) {
$_SESSION["ulogin"] = $record["ulogin"];
$_SESSION["uid"] = $record["uid"];
if($record["utype"] == 1){
$_SESSION["utype"] = $record["utype"];
header("Location:admin.php?uid=".$record["uid"]);
exit;
}else{
header("Location:home.php");
exit;
}
}
}
header("Location:login.php?invalid=1");
?>
您似乎以純文本格式保存密碼。請不要這樣做。另請注意,'mysql_'函數已被棄用,不應再使用。改爲使用PDO或MySQLi。 – Arjan 2013-03-14 11:41:07