Home >Backend Development >PHP Tutorial >用thinkphp写的用户登录界面,但是每次都说用户名或者密码不正确,求解?

用thinkphp写的用户登录界面,但是每次都说用户名或者密码不正确,求解?

WBOY
WBOYOriginal
2016-06-23 14:18:251489browse

<?phpsession_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();					}	}	?>

我不填提示我用户名或者密码不正确,我填正确了也提示我用户名或者密码不正确,不知道哪的问题,求解答。


回复讨论(解决方案)

tp 有自己的表单验证方法,为何不用?
如果在框架中还需要自己写基础代码,那么要用框架干什么?

只有逻辑提示会导致提示你密码不正确.这还找不出原因么.
要么post的数据有问题,要么sql有问题.打印出post的数据和sql语句看看.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn