I am using laravel 5.4 and I am create a form for insert data into the database and so I set a action and give url in action but it so me more error. that is
tokenmismatchexception in verifycsrftoken php line 68
at VerifyCsrfToken->handle(object(Request), object(Closure))
in Pipeline.php (line 148)
at Pipeline->IlluminatePipeline{closure}(object(Request))
in Pipeline.php (line 53)
at Pipeline->IlluminateRouting{closure}(object(Request))
in ShareErrorsFromSession.php (line 49)
at ShareErrorsFromSession->handle(object(Request), object(Closure))
in Pipeline.php (line 148)
at Pipeline->IlluminatePipeline{closure}(object(Request))
in Pipeline.php (line 53)
at Pipeline->IlluminateRouting{closure}(object(Request))
in StartSession.php (line 64)
My form is:
<form id=”login-form” action=”{{URL::to(‘signin’)}}” method=”post” role=”form”>
</form>
How can I solve this problem?
Hi, It’s very simple to fixed your problem. Just add the route name in the app/http/Middleware/VerifyCsrfToken.php file.
such as:
<?php namespace AppHttpMiddleware; use IlluminateFoundationHttpMiddlewareVerifyCsrfToken as BaseVerifier; class VerifyCsrfToken extends BaseVerifier{ /** * The URIs that should be excluded from CSRF verification. * * @var array */ protected $except = [ // 'route_name', //give the route name here which is in post ]; } ?>
I hope it will be pleasure for you.