2

I am using Laravel 5.3, the task that i am currently working on is the Form routing.

This is my routes.php file.

Route::group(['middleware' => 'web'], function() {
    Route::get('/login', ['as' => 'login', 'uses' => 'LoginController@login']);
    Route::post('/handleLogin', ['as' => 'handleLogin', 'uses' => 'LoginController@handleLogin']);
});

The actual Form code in the view.

    {!! Form::open(array('route' => 'handleLogin')) !!}
<div class="form-group">
    {!! Form::label('email') !!}
    {!! Form::text('email', null, array('class' => 'form-control')) !!}
</div>
<div class="form-group">
  {!! Form::label('password') !!}
  {!! Form::password('password', array('class' => 'form-control')) !!}
</div>
{!! Form::token() !!}
{!! Form::submit('Login', array('class' => 'btn btn-default')) !!}
{!! Form::close() !!}

The controller that has the handle function.

/* handleLogin function to request the data*/
public function handleLogin(Request $request){
    $data = $request-> only('email', 'password');
    if(\Auth::attempt($data)){
        return 'Is Logged In';
    return redirect()-> intended('/home');
    }

return back()->withInput();
}

When i click on Login button, a blank page is displayed instead of the page that would display 'Is Logged In'.

Any help would be appreciated.

Harsh
  • 187
  • 2
  • 2
  • 7

1 Answers1

0

You should remove web middleware from routes file since you're using Laravel 5.3 in which web middleware is added automatically. Adding it manually will cause problems.

Community
  • 1
  • 1
Alexey Mezenin
  • 158,981
  • 26
  • 290
  • 279
  • I tried that now, but when i submit the form i still get a blank page... – Harsh Dec 22 '16 at 19:15
  • Check for the last error in `/storage/logs/laravel.log`. Also, do not put `web` middleware back into routes file. – Alexey Mezenin Dec 22 '16 at 19:18
  • This is not an error, it's stack trace. Look right above stack trace (above #0). – Alexey Mezenin Dec 22 '16 at 19:23
  • Sorry. This is the last error [2016-11-21 12:10:48] local.ERROR: Symfony\Component\Debug\Exception\FatalThrowableError: Parse error: syntax error, unexpected end of file in /home/vagrant/Code/steelworks/routes/web.php:22 – Harsh Dec 22 '16 at 19:30
  • If it has timestamp of the moment when you're getting empty page, please post `web.php` somewhere. – Alexey Mezenin Dec 22 '16 at 19:32