<?php
class IndexAction extends Action {
function index(){
$this->display();
}
function do_login(){
//获取用户名和密码信息,和数据库中比对
// echo 111111111;
dump($_POST);
dump($_SESSION);
#sleep(10);
$username=$_POST['username'];
$password=$_POST['password'];
$code=$_POST['code'];
if($_SESSION['verify']!==md5($code)){
$this->error('验证码错误');
}
$m=new Model('user');
$where['username']=$username;
$where['password']=md5($password);
$arr = $m->where($where)->find();
$i=$m->where($where)->count();
if ($i>0){
$_SESSION['username']=$username;
$_SESSION['authority'] = $arr['authority'];
$this->redirect('Main/index');
}else{
$this->error('该用户不存在');
}
}
function checkUser(){
$username=$_POST['username'];
$m=new Model('user');
$where['username']=$username;
$i=$m->where($where)->count();
if ($i>0){
echo "1";
}else{
echo "0";
}
}
function checkPasswd(){
$username=$_POST['username'];
$password=$_POST['password'];
$m=new Model('user');
$where['username']=$username;
$where['password']=md5($password);
$i=$m->where($where)->count();
if ($i>0){
echo "1";
}else{
echo "0";
}
}
function checkCode(){
$code=$_POST['code'];
if($_SESSION['verify']!==md5($code)){
echo "0";
}else{
echo "1";
}
}
}
?>
登陆成功后跳转到 $this->redirect('Main/index'); 表示main类的index方法
<?php
// 本类由系统自动生成,仅供测试用途
class MainAction extends Action {
function _before_index(){
if(!isset($_SESSION['username']) || $_SESSION['username']=='')
{
$this->redirect('Index/index');
}
}
public function index(){
echo 'dasd2313`1312';
#sleep(10);
$this->display();
}
}
dasd2313`1312我跳转到Main/index
php的页面跳转通过后台方法控制