Home  >  Article  >  Backend Development  >  Why does the account and password keep getting wrong?

Why does the account and password keep getting wrong?

WBOY
WBOYOriginal
2016-07-06 13:51:351394browse

<code>public function postLogin(Request $request)
{
    if($input=Input::all()){
    if(!Auth::attempt(['phone' => $input['mobile'], 'password' => $input['password']])){
        return back()->with('msg', '用户名或者密码错误!');
    }
    return redirect('');
}</code>

I keep getting errors when using this method. Why? I tried it and the account and password are correct, but I keep getting errors because the username or password is wrong

Reply content:

<code>public function postLogin(Request $request)
{
    if($input=Input::all()){
    if(!Auth::attempt(['phone' => $input['mobile'], 'password' => $input['password']])){
        return back()->with('msg', '用户名或者密码错误!');
    }
    return redirect('');
}</code>

I keep getting errors when using this method. Why? I tried it and the account and password are correct, but I keep getting errors because the username or password is wrong

If you make sure your username and password are correct. Then you have to take a look at how your Auth::attempt() handles usernames and passwords. It is very likely that the problem lies in Auth::attempt()

Output the sql statement executed to see if the user password entered is correct

<code class="php">\DB::connection()->enableQueryLog();
$queries = \DB::getQueryLog();dd($queries );</code>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn