当前位置:Gxlcms > PHP教程 > thinkphp会员登录有关问题

thinkphp会员登录有关问题

时间:2021-07-01 10:21:17 帮助过:5人阅读

thinkphp会员登录问题

session_start();
header('Content-Type:text/html; charset=utf-8');
class AdminAction extends Action{
public function index(){
if(isset($_POST['username'])){
if(isset($_POST['username'])&&isset($_POST['password'])){
$db=M();
$select=$db->query("select * from developers where username=".$POST['username']." and password=".$_POST['password']."");
if($select){
$_SESSION['admin']=$_POST['username'];
$this->redirect('Index/index','',2,'用户'.$_POST['username'].'登录成功!');
}else{
$this->redirect('Index/index','',2,'用户名或者密码不正确');
}
}else{
$this->redirect('Index/index','',2,'用户名或密码不能为空!');
}
}
$this->display();
}



}
?>

这是AdminAction代码,不知道怎么回事,不管输入什么或者不输人它都提示用户名或者密码不正确,为什么呢?哪的问题?

分享到:


------解决方案--------------------
看看sql语句在数据库的查询结果有没有问题。
------解决方案--------------------
你确定你的sql没错??

"select * from developers where username='".$POST['username']."' and password='".$_POST['password']."'"

------解决方案--------------------
查询操作后面加上: echo $db->getLastSql();exit; 把sql语句打印出来就知道结果了。
------解决方案--------------------
引用:
Quote: 引用:

查询操作后面加上: echo $db->getLastSql();exit; 把sql语句打印出来就知道结果了。

用这个发现问题了,username不管我输入什么都打印不出来,password就没问题,这是哪的问题呢?没发现是哪写错了啊

表单里的name属性有没有写错
------解决方案--------------------
引用:
Quote: 引用:

Quote: 引用:

人气教程排行