Reputation: 2901
Router:
Route::post('/submit/{id}', function() {
return 'Hello World';
});
HTML:
<form method="POST" action="/submit/{{$id}}">
The above changes the URL to http://127.0.0.1:8000/submit/$id
and returns
Page has Expired Due to Inactivity.
It looks like Laravel is trying to force the POST into a GET.
Upvotes: 0
Views: 291
Reputation: 430
This problem is because you forget to put the CSRF token field into the form.
Try with:
Option 1
<form method="POST" action="{{url('submit', [$id])}}">
{{ csrf_field() }}
<button type="submit">Submit</button>
</form>
Option 2
<form method="POST" action="{{url('submit')}}/{{$id}}">
@csrf
<button type="submit">Submit</button>
</form>
For more info see this link
Upvotes: 1