简体   繁体   中英

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>

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM