<?phpinclude_once('../../libs/adodb/adodb.inc.php');$conn=NewADOConnection('mysql'); //创建adodb对象,声明数据库类型为MySql
$conn->debug=true; //显示错误信息
$conn->Connect("localhost","root","123","php_games");// 连接数据库,user是我自己建的数据库名字
$rs=$conn->Execute("select * from php_admin where p_name='".$user."' and p_pwd='".$pass."'");if($rs->GetRows())
{ if(!($_SESSION["username"])){
$_SESSION["username"]=$rs->fields[1];
} echo "<script>location.href='../index.php';</script>";
exit();
}
else
{
echo "<script>location.href='../login.php';</script>";
exit();
}
?>红色的那部分得不到值。
$conn->debug=true; //显示错误信息
$conn->Connect("localhost","root","123","php_games");// 连接数据库,user是我自己建的数据库名字
$rs=$conn->Execute("select * from php_admin where p_name='".$user."' and p_pwd='".$pass."'");if($rs->GetRows())
{ if(!($_SESSION["username"])){
$_SESSION["username"]=$rs->fields[1];
} echo "<script>location.href='../index.php';</script>";
exit();
}
else
{
echo "<script>location.href='../login.php';</script>";
exit();
}
?>红色的那部分得不到值。
得值,好像和这里有关,if($rs->GetRows()) 如果写成if($rs) 就会得到 $rs->fields[1] 他得值,不值到为什么
改成if($rs->GetRows()>0)试试
$rs->fields[1]
还是什么也接受不到