Made a simple form, wrote a route for the file to which the form will be sent using the POST method. As a result, an error occurs. What can be wrong? I tried to change POST to GET - then it works. PS The code is presented by screenshots, since it did not work to show it exactly "as a code". 
|
1 answer
There is no secure token. Put the
{{csrf_field()}} or
<input type="hidden" name="_token" value="{{csrf_token()}}" Replace
<form action="/comments" method="post"> on
<form action="{{Route("comments")}}" method="post"> In the route
Route::post("comments", funciton(Illuminate\Http\Request $request){ pritn_r($request);//$request то есть $_POST, $_POST['title'] это $request['title]; })->name("comments"); // у каждого роута должно быть имя - Added line <input type = "hidden" name = "_ token" value = "{{csrf_token ()}}"> to the form - does not help. And where to add only {{csrf_field ()}}? - Djonson
- Inside the form tag. {{csrf_field ()}} and <input type = "hidden" name = "_ token" value = "{{csrf_token ()}}" is the same. {{csrf_field ()}} shortened - James
- laravel.com/docs/5.4/routing see here - James
- Something does not help. But I did it like this: You can disable the CSRF token checking for a specific route by adding it (route) to the $ except field in the VerifyCsrfToken middleware: - Djonson
|

