2017-10-18 298 views
0

我有一個註冊問題。當用戶完成註冊後,他會在RouteCollection.php第219行中得到這個錯誤消息 - MethodNotAllowedHttpException。如果你會導致這個錯誤的問題,你可以檢查你的代碼。Laravel 5.1 MethodNotAllowedHttpException - 註冊

01.)routes.php文件

/** 
 
    * Guest only visit this section 
 
    */ 
 
    Route::group(['middleware' => 'guest'], function() { 
 
     Route::get('account/login', ['as' => 'login', 'uses' => 'Auth\[email protected]']); 
 
     Route::get('auth/{provider}', 'Auth\[email protected]'); 
 
     Route::get('auth/{provider}/callback', 'Auth\[email protected]'); 
 
     Route::get('registration/{provider}', 'Auth\[email protected]'); 
 
     Route::get('account/registration', ['as' => 'registration', 'uses' => 'Auth\[email protected]']); 
 
     Route::get('registration/activate/{username}/{code}', 'Auth\[email protected]'); 
 
     Route::get('password/email', ['as' => 'password.reminder', 'uses' => 'Auth\[email protected]']); 
 
     Route::get('password/reset/{token}', 'Auth\[email protected]'); 
 
    }); 
 

 
    /** 
 
    * Guest Post form with csrf protection 
 
    */ 
 
    Route::group(['middleware' => 'csrf:guest'], function() { 
 
     Route::post('account/login', 'Auth\[email protected]'); 
 
     Route::post('registration/{provider}', 'Auth\[email protected]'); 
 
     Route::post('password/email', 'Auth\[email protected]'); 
 
     Route::post('password/reset/{token}', 'Auth\[email protected]'); 
 
     Route::post('account/registration', 'Auth\[email protected]'); 
 
     Route::get('image/freefiles/{slug}', ['as' => 'images.freefiles', 'uses' => '[email protected]']); 
 
    });

02.)login.blade.php

<form action="{{url('/registration')}}" method="POST"> 
 
            <input type="hidden" name="_token" value="{{ csrf_token() }}"> 
 
            <div class="sminputs"> 
 
             <div class="input full"> 
 
              <label class="string optional" for="username">username*</label> 
 
              <input class="string optional" maxlength="255" id="username" name="username" placeholder="username" type="text" size="50" /> 
 
             </div> 
 
            </div> 
 
            <div class="sminputs"> 
 
             <div class="input full"> 
 
              <label class="string optional" for="email">Email*</label> 
 
              <input class="string optional" maxlength="255" id="email" name="email" placeholder="Email" type="email" size="50" /> 
 
             </div> 
 
            </div> 
 
            <div class="sminputs"> 
 
             <div class="input string optional"> 
 
              <label class="string optional" for="password">Password *</label> 
 

 
              {!! Form::password('password',['class'=>'form-control input-lg','placeholder'=>t('Enter Password'),'autocomplete'=>'off','required'=>'required']) !!} 
 
             </div> 
 
             <div class="input string optional"> 
 
              <label class="string optional" for="password_confirmation">Repeat password *</label> 
 

 
              {!! Form::password('password_confirmation',['class'=>'form-control input-lg','placeholder'=>'Confirm Password','autocomplete'=>'off','required'=>'required']) !!} 
 
             </div> 
 
            </div> 
 
            <div class="simform__actions"> 
 
             <input class="sumbit" name="commit" type="submit" value="Create Account" /> 
 

 
             <span class="simform__actions-sidetext">By creating an account you agree to our <a class="special" href="#" target="_blank" role="link">Terms & Privacy</a></span> 
 
            </div> 
 
           </form>

03.)login_beta.blade .php

<form action="{{url('registration')}}" class="contact_form2" method="POST"> 
 
      <h1 style="text-align: center">Create Your Account</h1> 
 
      <input type="hidden" name="_token" value="{{ csrf_token() }}"> 
 
      <ul id="usn_eml"> 
 
       <li> 
 
        <input type="text" maxlength="255" id="username" name="username" class="textbox1" 
 
        placeholder="Your username..." required/> 
 
        <span class="form_hint">Enter username</span> 
 
       </li> 
 
       <li> 
 
        <input type="email" maxlength="255" id="email" name="email" class="textbox1" 
 
        placeholder="Your email..." required> 
 
        <span class="form_hint">Enter email...</span> 
 
       </li> 
 
       <li> 
 
        {!! Form::password('password',['class'=>'textbox1','placeholder'=>t('Enter Password'),'autocomplete'=>'off','required'=>'required']) !!} 
 
        <span class="form_hint">Your password...</span> 
 
       </li> 
 
       <li> 
 
        {!! Form::password('password_confirmation',['class'=>'textbox1','placeholder'=>'Confirm Password','autocomplete'=>'off','required'=>'required']) !!} 
 
        <span class="form_hint">Confirm password...</span> 
 
       </li> 
 
\t \t \t \t <ol style="clear: both; display: block; padding-top: 17px;"> 
 
       
 
       <div class="form-group"> 
 
        <script src='https://www.google.com/recaptcha/api.js'></script> 
 

 
        <div class="g-recaptcha" data-sitekey="xxxx"></div> 
 
       </div> 
 
      
 
\t \t \t </ol> 
 
       <input name="commit" type="submit" value="Create Account"/> 
 
       
 
      </ul> 
 

 
      <style> 
 
       #usn_eml { 
 
        width: 50%; 
 
        display: block; 
 
        margin: auto; 
 
       } 
 
      </style> 
 

 
      
 

 
      <div class="tos"> 
 
       By creating an account you agree to our <a 
 
       class="special" href="http://pixsector.com/p/terms-of-service" target="_blank" role="link">Terms & 
 
       Privacy</a> 
 
      </div> 
 

 
      <div class="already_member"> 
 
       <p>Already a member? Please<a id="getSignInDiv" href="#"> Sign In</a></p> 
 
      </div> 
 
     </form>

+0

這是什麼'csrf:guest'? –

+2

你的帖子'註冊'方法在哪裏? –

+0

您在路由文件中缺少'post' route'registration'。這是'MethodNotAllowedHttpException'告訴的內容。 –

回答

0

你有兩條路線具有相同的URL,因此它似乎您試圖張貼於獲取路線,你應該給你的路由的名稱,所以你沒有這個問題是這樣的:

Route::post('registration/{provider}', ['as'=>'registration.store', 'uses'=>'Auth\[email protected]']); 

然後在你的刀你打電話給你的行動像這樣

action="{{ route('registration.store', ['provider' => $provider]) }}" 

你沒有在刀片中傳遞任何參數,並且你的路線期待着一個;

+0

這段代碼沒有幫助 – vectorization

相關問題