0 レビュー
3 回答
php-エラーがMethodNotAllowedHttpExceptionである理由がわかりません
Laravel 4.2+Sentryでログインフォームを作成しようとしています。問題は、フォームを送信すると、メソッドが許可されていないというエラーが発生したことです。
ソースでフォームを確認すると、 method="POST"
があり、 post
を書いたルートにもあります。何が問題になる可能性がありますか?
MethodNotAllowedHttpException
しかし、理由がわかりませんか?これがフォームです
{{ Form::open(array('route' => 'check-auth')) }} <div class="body bg-gray"> {{-- Display flash message --}} @if (Session::has('flash_message')) <span style="margin-left:18%; color: #ff0000">{{ Session::get('flash_message') }}</span> @endif <div class="form-group"> <input type="text" name="email" class="form-control" placeholder="User email"/> @if($errors->has('login_errors')) <span class="has-error">{{ $errors->first('email') }}</span> @endif </div> <div class="form-group"> <input type="password" name="password" class="form-control" placeholder="User password"/> </div> <button type="submit" name="submitbtn" class="btn bg-olive btn-block">Sign me in</button> </div> {{ Form::close() }}
ルート
Route :: post('user-login'、['as' =>'check-auth'、'uses' =>'AuthenticationController @ login']);
およびコントローラー
public function login() { try{ $credentials = array( 'email' => Input::get('email'), 'password' => Input::get('password') ); $user = Sentry::authenticate($credentials, false); if($user){ return Redirect::to('dashboard'); } return Redirect::to('/')->with('title','Login errors'); } catch(Exception $e){ echo $e->getMessage(); Session::flash('flash_message', 'No access!'); return Redirect::to('/')->with('title','Login errors'); } }
更新:エラー
production.ERROR: Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException in /var/www/html/time/vendor/laravel/framework/src/Illuminate/Routing/RouteCollection.php:210
わからない
0
レビュー
答え :
解決策:
ルートは正しいです。私が提案できる唯一のことは、フォームの先頭にタイプを追加することです: {{ Form::open(['url' => 'check-auth', 'method' => 'post']) }}
わからない
0
レビュー
答え :
解決策:
{{Form :: open(array('route' =>'check-auth'))}}
参照してください。ルートチェック認証を使用しており、ルートファイルで別のルートを定義しました。つまりユーザーログイン
Route::post('user-login', ['as'=>'check-auth', 'uses'=>'[email protected]']);
ルートを修正して再試行してください。これでうまくいきます
わからない
同様の質問
私たちのウェブサイトで同様の質問で答えを見つけてください。