PHP头条
热点:

thinkphp会员登录有关问题


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: 引用:

www.phpzy.comtrue/phprm/8978.htmlTechArticlethinkphp会员登录有关问题 thinkphp会员登录问题 session_start(); header('Content-Type:text/html;charset=utf-8'); classAdminActionextendsAction{ publicfunctionindex(){ if(isset($_POST['username'])){ if(isset($_POST['username'])is...

相关文章

相关频道:

PHP之友评论

今天推荐