简体   繁体   English

Laravel 5,单击表单提交按钮时不显示任何内容

[英]Laravel 5, nothing displayed when form submit button is clicked

I am using Laravel 5.3, the task that i am currently working on is the Form routing. 我正在使用Laravel 5.3,我目前正在处理的任务是表单路由。

This is my routes.php file. 这是我的routes.php文件。

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代码。

    {!! 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. 任何帮助,将不胜感激。

You should remove web middleware from routes file since you're using Laravel 5.3 in which web middleware is added automatically. 您应该从路由文件中删除web中间件,因为您使用的是Laravel 5.3,其中自动添加了web中间件。 Adding it manually will cause problems. 手动添加它会引起问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM