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语句打印出来就知道结果了。
------解决方案--------------------
表单里的name属性有没有写错
------解决方案--------------------
PHP之友评论