zoukankan      html  css  js  c++  java
  • 【项目练习】控制器直接操作--登录

    控制器

    <?php
    
    namespace appadmincontroller;
    
    use thinkController;
    use thinkValidate;
    use thinkDb;
    use thinkModel;
    
    class Index extends controller
    {
      //登陆后台
      public function login()
      {
    
        if (request()->isAjax()) {
          $validate = new Validate([
            'username|用户名'  => 'require',
            'pwd|密码' => 'require'
          ]);
          $data = [
            'username' => input("post.username"),
            'pwd' => input('post.pwd')
          ];
          if (!$validate->check($data)) {
            $this->error($validate->getError());
          }
          $res = Db::name('admin')->where($data)->count();
          if ($res == 1) {
            $this->success('登陆成功', 'admin/home/index');
          } else {
            $this->error('用户名或密码不正确');
          }
        }
        return view();
      }
    }

    没有多层的束缚,直接操作数据库,但是无法使用软删除等操作

  • 相关阅读:
    Lua 的元表怎么理解
    Lua中的元表与元方法
    Lua 的元表怎么理解
    VMware Workstation 系统备份-虚拟机克隆方法
    Lua中的元表与元方法
    bzoj2809
    bzoj2733
    bzoj1334
    bzoj1211
    bzoj3083 3306
  • 原文地址:https://www.cnblogs.com/xiaozhang666/p/11555815.html
Copyright © 2011-2022 走看看