Tuesday, March 31, 2015

[Laravel][Resolved] Error methodnotallowedhttpexception in Laravel 4



In php, there are two ways the browser client can send information to the web server:

•  GET Method
•  POST Method

For my case, I used “POST” as the method to send the form to web server but set use “GET” method to route. Request is made with a request method not supported, (POSTing to a GET route) so that it causes an error.

View:
<form method="POST" action="{{Request::url()}}">

Route.php
Route::get('test/create/', 'TestController@overviews');

Solution:
If you use POST method to post the form data. Change your route statement at route.php to post method:
Route::post('test/create/', 'TestController@overviews');

***** OR *****
If you use GET method to send the form data. Change value of method attribute in your form to “get” in your view.
<form method="GET" action="{{Request::url()}}">
Update:
If still don't work, you can try use this at route:
Route::match(array('GET', 'POST'), ''test/create/', 'TestController@overviews');

Reference:
http://www.tutorialspoint.com/php/php_get_post.htm
http://wenda.golaravel.com/question/52
http://stackoverflow.com/questions/17501653/methodnotallowedhttpexception-laravel-4
http://stackoverflow.com/questions/19760585/laravel-throwing-methodnotallowedhttpexception
http://stackoverflow.com/questions/18326030/how-to-route-get-and-post-for-same-pattern-in-laravel

No comments :

Post a Comment