The verification code in the Thinkphp5 teaching management system keeps prompting an error and cannot be logged in.
SEC
SEC 2017-09-06 12:56:45
0
4
1576

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

SEC
SEC

reply all(3)
kevlin

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

LauEl
这个地方查询数据库是有问题的
在头部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];

}


唐位辉

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


  • reply Your judgment is correct. It is a database problem. It only takes a long time to solve the database problem.
    兰羽馨 author 2017-10-27 09:49:28
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template