Redirecting a user after login in php laravel

  html, laravel, php

Hi guys I am using Auth method in Laravel to try to print ‘logged in successfully’ if the user has provided correct credentials and to print ‘sorry you have entered wrong credentials’ if the user has not entered the correct credentials. But the problem is that am always getting the false statement I.e. ‘sorry you have entered the wrong credentials’ despite entering the correct credentials. What could have been the problem? Here is an extract of part of my code;

    /*This the login form */

<div class="form-control">
{!!Form::open(['url'=>'retrive', 'method' => 'GET' ])!!}

{{Form::text('email'),['class'=>'form-group', 'placeholder'=>'Enter email']}}
{{Form::text('password'),['class'=>'form-group', 'placeholder'=>'password']}}

/*This below is the router which will receive the credentials from the search.blade.php and submit to retrive function in Getfrom controller*/

/*Routes>web.php */


use AppHttpControllersGetfrom;
Route::get('/retrive',[Getfrom::class, 'retrieve']);

/*This is the name of the public function under Getfrom controller where the router will submit the  login credentials*/

public function retrieve(Request $request)
        if(Auth::attempt(['email'=>$request->email, 'password'=>$request->password]))
        return 'logged in succesfully';
        return 'sorry wrong credentials';

All passwords am trying to retrieve have been hashed (bcrypt) in the database.

Source: Laravel

Leave a Reply