laravel 5.3中的MethodNotAllowedHttpException

时间:2017-02-15 10:25:43

标签: php laravel-5.3

我正在使用laravel 5.3并希望在提交登录页面时将api_token作为查询字符串附加到student / dashboard url,如下所示:

http://localhost/Exams/student/dashboard?api_token=4ZtxTu7fAwYpcPYRu46GWmVfncPO0i

但是每当调用postSudentLogin方法时,它总是抛出MethodNotAllowedException。它在地址栏中显示正确的URL,但始终在RouteCollection.php第218行'中抛出' MethodNotAllowedHttpException。

以下是我的代码: Login.blade.php:

<form  class="form-horizontal" id="post_req" role="form" name="User" method="post" action="{{ url('student/dashboard') }}" >

              <input type="hidden" name="_token" value="{{ csrf_token() }}">                        
                <div class="form-group">
                    <label for="inputEmail3" class="col-sm-3 control-label">Email :</label>
                    <div class="col-sm-9">
                        <input type="email" class="form-control" id="email" name="email" placeholder="Email" required/>                          
                    </div>
                </div>

我的LoginController.php是:

     public function postStudentLogin(){         
        $student =  DB::table('students')->where('email', Input::get('email'))->first();
        if(Hash::check( Input::get('password'),$student->password)){
          Session::flash('login_message','You have been logged in successfully.');        
          // return view('student.dashboard');            
          return redirect()->route('dashboard',['api_token'=> $student->api_token]);                
        }
        else{                             
          return redirect()->back()->withErrors('Incorrect username/password');
        }               
    }

路由\ web.php:

Route::group(['prefix' => 'student', 'namespace' => 'Auth'], function(){
   Route::get('/','Student\LoginController@getStudentHome');    
   Route::get('/login/{page}',['uses' => 'Student\LoginController@getStudentLogin' ]);  
   Route::post('/dashboard',['uses' =>'Student\LoginController@postStudentLogin'])->name('dashboard');      
});

请指导我哪里错了。我被困在这里。

谢谢, Dipti Sheth

0 个答案:

没有答案