Hi,
Here is relevant chunk of code from routes.php
Route::post('testPost', function(){
echo "Post received";
});
When I hit it with POST request I get 500 Internal server error, but if I change first line so it handles get requests like:
Route::get('testPost', function(){
...
everything works fine.
My .htaccess file is as default.
Does anyone have an idea what can be the solution?
It would be helpful if you show your form code. Also make sure you have a csrf token on form, see the docs.
I'm using hurl.it to generate post request. I'm just setting request type to post and specify URL. Is there a something else that needs to be added?
I am having the same problem all of a sudden, but only with one form on a site where there are many many forms and routes. In my HTML I have:
<main class="container">
<form class="form-horizontal" action="/pallet/save" method="post" accept-charset="utf-8" role="form">
<div class="row">
<div class="col-xs-12">
<div class="pm-well">
<h2>Scan Add Pallet</h2>
<div class="form-group">
<label class="col-xs-12 col-sm-2" for="location">Location: </label>
<div class="col-xs-12 col-sm-8">
<input type="text" class="form-control" name="location" id="location">
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<input type="submit" class="pm-btn pm-btn-confirmation medium-btn" value="Add Pallet">
</div>
</div>
</form>
</main>
And in my routes file I have:
The error I get is:
~~~ Call to undefined method Illuminate\Http\Request::post() ~~~
I've tried changing the Route to Route::any but get the same error.
This is the only form submission that is throwing that error; all the other forms work as expected so I'm kinda stumped here as to what the problem is.
As a control test, I copied my html form and setup a straight html and php (not using Laravel or any other PHP framework) webroot with a separate virtual host domain and changed the form action to point to another php script where I can echo out the post data and server request methods via PHP's super globals ($_SERVER['REQUEST_METHOD'] & $_POST).
Everything works as expected this way. Is there a chance that some bug has been introduced? Like I said, I have several web sites built in Laravel 4 each of which has many routes and form submissions and have never encountered this before.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community