返回登录验证模块...登陆

登录验证模块

千 夜2019-05-29 20:54:21210

<?php


namespace app\admin\controller;


use app\admin\model\UserModel;

use think\Controller;

use think\facade\Request;

use think\facade\Session;

class Login extends Controller

{

public function login()

{

//渲染登录界面

return $this->fetch();

public function Dologin()

{

        //获取前台提交的数据

        $data = Request::param();

        $username = $data['username'];

        //使用变量作为查询条件到数据库中查询对应的数据

        $user = UserModel::where('username',$username)->find();

        if($user != true){

        $info = ['res'=>0,'msg'=>'用户名不存在!'];

        }elseif($data['password'] != $user['password']){

        $info = ['res'=>0,'msg'=>'密码错误!'];

        }else{

        $info = ['res'=>1,'msg'=>'登录成功!'];

        Session::set('username',$user['username']);

        }

        return $info;

}

public function LoginOut()

{

Session::delete('username');

$this->redirect('login');

}

}


最新手记推荐

• 用composer安装thinkphp框架的步骤• 省市区接口说明• 用thinkphp,后台新增栏目• 管理员添加编辑删除• 管理员添加编辑删除

全部回复(0)我要回复

暂无评论~
  • 取消回复发送
  • php.cn