<?php
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代码,不知道怎么回事,不管输入什么或者不输人它都提示用户名或者密码不正确,为什么呢?哪的问题?
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代码,不知道怎么回事,不管输入什么或者不输人它都提示用户名或者密码不正确,为什么呢?哪的问题?
表单里的name属性有没有写错
表单里的name属性有没有写错
当然不可能写错了怎么会犯那么低级的错误...
表单里的name属性有没有写错
当然不可能写错了怎么会犯那么低级的错误...你的password没有MD5?
首先password md5了。数据库里也md5了。直接打印也还是没有username。密码能打印出来,就是username打印不出来
发现问题了没
username='".$_POST['username']."'
我晕,你发现了居然不指出来,他们也没发现,坑爹啊,直到现在才明白....
应该是$select=$db->query("select * from developers where username=".$_POST['username']." and password=".$_POST['password']."");
我晕,你发现了居然不指出来,他们也没发现,坑爹啊,直到现在才明白....
应该是$select=$db->query("select * from developers where username=".$_POST['username']." and password=".$_POST['password']."");
username='".$_POST['username']."'这种地方都要加上单引号