NAME NO
NAME NO

Reputation: 75

419 unknown status in form post request

I am a beginner in laravel framework. Now I am creating a form which will send post request to /abc.php. However, after submitting the form, error unknown server error with status 419 is reported.

I have googled about this issue and I figured out that it was caused by csrf_token. I tried to except verify csrf token in this route and forms were submitted successfully.

Therefore, I have added {{ csrf_field() }} after the <form>tag and submit the form again but the form submit failed. Except not verifying the csrf token in my form, what can cause this problem? Thank you very much!

My route

Route::post('/abc.php','formSubmitController@submit');

My form

<form class="myform" name="myform" id="myform" method="post" action="/abc.php" onsubmit="return validation();"  enctype="multipart/form-data"> 
<input type="hidden" name="_token" value="{{ csrf_token() }}">
....
</form>

Upvotes: 2

Views: 5320

Answers (1)

Akbar Soft
Akbar Soft

Reputation: 1066

try so...

Route::post('/abc','formSubmitController@submit')->name('abc');


<form class="myform" method="post" action="{{route('abc')}}" onsubmit="return validation();"  enctype="multipart/form-data"> 
@csrf
....
</form>

Upvotes: 2

Related Questions