2

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>
NAME NO
  • 75
  • 3
  • 10

1 Answers1

2

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>
Akbar Soft
  • 1,028
  • 10
  • 19
  • Thank you for your answer. But I am not sure if I need to add `@csrf` right next to the form tag? I tried but it simply shows `@csrf` in the form. – NAME NO Aug 24 '18 at 06:05