zoukankan      html  css  js  c++  java
  • 问答项目---账号密码异步校验后进行PHP校验

    在做登陆的时候,通过异步校验后还需要通过PHP来校验账号和密码的正确性。

    PHP校验账号密码:

    public function login(){
        if(!IS_POST){echo "页面不存在"; $this->redirect('index'); die();};       
        $username = I('post.username');
        $pwd = I('post.password','','md5');
        $code = I('post.code');
        $obj = new ThinkVerify();
        if(!$obj->check($code)){
            $this->error('验证码错误');
        };
        //验证账号和密码       
        $where = array(
            'account' => $username
        );        
        $result = M('admin')->where($where)->find();   
        if(!$result || $result['password'] != $pwd){
             $this->error('账号或密码错误');
        };
        if($user['lock']){
            $this->error('账号被锁定');
        };
        $data = array(
            'id' => $result['id'],
            'logintime' => time(),
            'loginIp' => get_client_ip()
        );
        M('admin')->save($data);
        // 存session
        session('uid',$result['id']);
        session('uid',$result['account']);
        session('logintime',date('y-m-d H:i',$result['logintime']));
        session('loginip',$result['loginip']);
        $this->redirect('/admin/index','',2,'页面正在跳转中...');
    }
  • 相关阅读:
    php中防盗链使用.htaccess
    使用Apache的.htaccess就可以防盗链
    左连接和右链接的区别?
    大量查询SQL语句 实例
    java项目打包
    java小项目
    哈夫曼树
    广义表
    树和森林的遍历
    根据前序中序,中序后序建立二叉树
  • 原文地址:https://www.cnblogs.com/e0yu/p/7355484.html
Copyright © 2011-2022 走看看