这是代码!当数据已经在数据库中时,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