Laravel Error Message MethodNotAllowedHttp Submit Update Form

Posted on

This article is an article written to explain an error happened as stated in the title of this article. The error which is happened in a web-based application powered by Laravel is an error with the message of MethodNotAllowedHttp. The error message happened when a form is being submitted and the form itself is actually a form which is sending the content of the form. The content of the form consists of several and various input type where there are several data which is automatically passed from the view blade file template to a controller.

Below is the image displaying the error message stated in the title of the article :

Basically, there is something wrong in the route definition which the conclusion itself is retrieved from the above image. The following snippet code is taken from the route definition file or route configuration file named ‘web.php’ which in Laravel 5.3 is located in the folder or routes/. The file location is shown in the tree format displayed in the following using the command execution of ‘tree’ :

user@hostname:/var/www/html/laravel-project$ tree -aL 1 routes/
├── api.php
├── console.php
└── web.php

0 directories, 3 files

Below is the route definition taken from the file named web.php located in the ‘routes’ folder :


One thing which is considered wrong in the route definition when a submit is being posted is in the method defined to execute the URL and the method processed it. The above route definition is using ‘get’ method, while the form definition used to submit a form is ‘post’. Below is the form definition which is located in a file named ‘edit.blade.php’ :

{{ Form::open(array('url' => '/user/update/'.$data['user']->id, 'class' => 'form-horizontal', 'id' => 'user_form'))}}
<input id="id_user" name="id_user" type="hidden" value="{{$data['user']->id}}">
<div class="form-group">
<label class="col-md-2 control-label">Name</label>
<div class="col-md-10">
<input type="text" class="form-control" placeholder="Name" name="name"
<span class="text-danger" id="name" />
<div class="form-group">
<div class="col-md-4 col-md-offset-2">
<input type="submit" id="user_button" class="btn btn-default" value="Next">
{{ Form::close()}}

The above form is a form used to edit user and it is actually taken just a part of the form. When there is a form as shown above with the main purpose of the form is for passing data from several input type field, the route configuration file itself must be defined as follows :


Just try it with a simple form to prove it.

One thought on “Laravel Error Message MethodNotAllowedHttp Submit Update Form

Leave a Reply