0

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.

seamus
  • 2,681
  • 7
  • 26
  • 49

1 Answers1

1

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

Maru Amallo
  • 430
  • 5
  • 11