title: Laravel - Method Not Allowed HTTP Exception (RouteCollection.php line 218)
body: <p>I'm currently new on Laravel and trying to develop my first project. I have this <code>MethodNotAllowedHttpException in RouteCollection.php line 218</code> error during my development for inserting data into database. I have searched both Google &amp; Stackoverflow for solutions but non are related to my current problem and some of them way too complex for this simple problem (I think so...).</p>
  
  <p>I have my form in my checklist page:-</p>
  
  <pre><code>&lt;form action="{{url('addchecklist')}}" method="POST"&gt;
              {{ csrf_field() }}
              &lt;div class="row"&gt;
                  &lt;div class="col-sm-12"&gt;
                      &lt;div class="text-left"&gt;
                          &lt;input type="hidden" name="schmFK" value="{{$id}}"&gt;
                          &lt;div class="col-sm-6"&gt;
                              &lt;h4&gt;
                                  &lt;label&gt;Section&lt;/label&gt;
                                  &lt;select class="selectpicker form-control" data-live-search="true" name="sctionPK"&gt;
                                      &lt;option selected&gt;Select the Section&lt;/option&gt;
                                      @foreach ($sction as $key=&gt;$slct1)
                                      &lt;option value="{{$slct1-&gt;ssctionPK}}"&gt;{{strtoupper($slct1-&gt;ssctionName)}}&lt;/option&gt;
                                      @endforeach
                                  &lt;/select&gt;
                              &lt;/h4&gt;
                          &lt;/div&gt;
                          &lt;div class="col-sm-2"&gt;
                          &lt;button type="button" data-toggle="modal" data-target=".bs-example-modal-lg" class="btn btn-primary btn-sm" style="margin-top:33px; padding-top:7px; padding-bottom:7px;"&gt;Add Section&lt;/button&gt;
                          &lt;/div&gt;
                          &lt;div class="col-sm-4"&gt;
                              &lt;h4&gt;
                                  &lt;label&gt;Severity&lt;/label&gt;
                                  &lt;select class="selectpicker form-control" name="svrityPK"&gt;
                                      &lt;option selected&gt;Select the Severity&lt;/option&gt;
                                      @foreach ($svrity as $key=&gt;$slct2)
                                      &lt;option value="{{$slct2-&gt;severityPK}}"&gt;{{strtoupper($slct2-&gt;severityName)}}&lt;/option&gt;
                                      @endforeach
                                  &lt;/select&gt;
                              &lt;/h4&gt;
                          &lt;/div&gt;
                          &lt;div class="col-sm-12"&gt;
                              &lt;h4&gt;
                                  &lt;label&gt;Question&lt;/label&gt;
                                  &lt;input class="form-control" type="text" placeholder="Question" name="question"&gt;
                              &lt;/h4&gt;
                          &lt;/div&gt;
                          &lt;div class="col-sm-6"&gt;
                              @include('widgets.button', array('class'=&gt;'primary btnaddstd', 'size'=&gt;'lg', 'type'=&gt;'submit', 'value'=&gt;'Add Checklist'))
                          &lt;/div&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/form&gt;
  </code></pre>
  
  <p>Then I have this route for inserting data from the form into database:-</p>
  
  <pre><code>Route::post('/addchecklist', function (Request $request){
  
      // Create instance to store record
      $scheme = new App\checklists;
      $scheme-&gt;schmFK = $request-&gt;schmFK;
      $scheme-&gt;schSectionFK = $request-&gt;sctionPK;
      $scheme-&gt;severityFK = $request-&gt;svrityPK;
      $scheme-&gt;clQuestion = $request-&gt;question;
      $scheme-&gt;save(); // save the input
  
  
      // Sort all records descending to retrieve the newest added record
      $input = App\checklists::orderBy('cklistPK','desc')-&gt;first();
  
      // Set search field variable default value of null
      $src = isset($src) ? $src : null;
  
      // Get Checklist reference from cklists_stddetails with the designated ID
      $chkstd = App\Cklists_stddetail::where('cklistFK', $input-&gt;cklistPK)
                                  -&gt;join('stddetails', 'stdDtlFK', '=', 'stddetails.sdtlPK')
                                  -&gt;get();
  
      // Get the newest stored record
      $chcklst = App\checklists::where('cklistPK', $input-&gt;cklistPK)-&gt;firstOrFail();
  
      // Get all data from table 'stddetails'
      $stddetail = App\stddetails::all();
  
      // Get all data from table 'standards'
      $stndrd = App\standard::all();
  
      // Get all data from table 'sections'
      $sction = App\Section::all();
  
  
      // Redirect to 'addref.blade' page with the newest added record
      return redirect('addref/'.$input-&gt;cklistPK)
          -&gt;with('src', $src)
          -&gt;with('chkstd', $chkstd)
          -&gt;with('id',$input-&gt;cklistPK)
          -&gt;with('schmid', $request-&gt;schmFK)
          -&gt;with('chcklst', $chcklst)
          -&gt;with('stddetail', $stddetail)
          -&gt;with('stndrd', $stndrd)
          -&gt;with('sction', $sction);
  });
  </code></pre>
  
  <p>My scenario is this, I have a form for user to input data in it. Then when the data is saved, they will be redirected to the page of that data to do something there. <strong>The data is successfully saved</strong> in the database but the redirection to the designated page (addref.blade) with the newest record ID return error:-</p>
  
  <p><a href="https://i.stack.imgur.com/oDzQO.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oDzQO.jpg" alt="MethodNotAllowedHttpException Error"></a></p>
  
  <p>But the URL goes where I wanted it to go (means the <strong>URL is right</strong>):-</p>
  
  <p><a href="https://i.stack.imgur.com/Uli3P.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Uli3P.jpg" alt="Success URL"></a></p>
  
  <p>As you can see, the usual solution from the net that I found are:-</p>
  
  <p><em>Make sure both method from routes and the form is the same</em>, and mine it is:-</p>
  
  <pre><code>method="POST"
  
  Route::post
  </code></pre>
  
  <p><em>Make sure the URL routes can recognize the form's action URL</em>, and mine it is:-</p>
  
  <pre><code>&lt;form action="{{url('addchecklist')}}" method="POST"&gt;
  
  Route::post('/addchecklist', function (Request $request)
  </code></pre>
  
  <p><em>Include CSRF token field in the form</em>, and mine it have been included:-</p>
  
  <pre><code>&lt;form action="{{url('addchecklist')}}" method="POST"&gt;
              {{ csrf_field() }}
  </code></pre>
  
  <p>I have tried those simple solution provided on the net and nothing is helpful enough. I'm still wondering what else I have missed and hoped that anyone here can assist on solving my issue.</p>