search

Home  >  Q&A  >  body text

The verification code in the Thinkphp5 teaching management system keeps prompting an error and cannot be logged in.

登陆界面提示.pnghtml文件中JS的ajax.pngPHP.png

SECSEC2645 days ago1579

reply all(4)I'll reply

  • kevlin

    kevlin2017-09-07 18:25:10

    I also encountered this problem, here’s how I solved it

    The parameters in $map and the database fields must be the same, otherwise there will be no response after the first click, and the verification code will be wrong the second time

    1.png

    reply
    2
  • LauEl

    LauEl2017-09-06 16:30:55

    这个地方查询数据库是有问题的
    在头部use think\Db;
    
    public function checkLogin(Request $request) {
        //初始化返回参数
        $state = 0;
        $result = '';
        $data = $request->param();
        $rule = [
            'name|用户名' => 'require',
            'password|密码' => 'require',
            'verify|验证码' => 'require|captcha',
        ];
        //自定义验证识别的提示信息
        $msg = array('name' => array('require' => '用户名不能为空,请检查您的用户名!'),
            array('password' => array('require' => '密码不能为空,请检查您的密码~')),
        );
        //validate 验证规则      1数据  2规则 3提示
        $result = $this->validate($data, $rule, $msg);
        //如果验证通过执行查询
        if ($result === true) {
            //构造查询条件
            $map = [
                'name' => $data['name'],
                'password' => md5($data['password'])
            ];
            $user = Db::table('user')->where($map)->find();
    
            if (!$user) {
                $result = '没有该用户,请检查';
            } else {
                $state = 1;
                $result = '验证通过,点击[确定]后进入后台';
            }
    
        }
        //进行验证
        return ['state' => $state, 'message' => $result, 'data' => $data];
    
    }


    reply
    1
  • SEC

    SEC2017-09-06 13:51:06

    The error code is: Failed to load resource: the server responded with a status of 500 (Internal Server Error)


    reply
    0
  • 兰羽馨

    Your judgment is correct. It is a database problem. It only takes a long time to solve the database problem.

    兰羽馨 · 2017-10-27 09:49:28
  • Cancelreply