[英]TokenMismatchException in VerifyCsrfToken.php line 53 (Laravel)
I read some questions about this problem, and I use this input in my form: 我阅读了有关此问题的一些问题,并在表单中使用了此输入:
<input type="hidden" name="_token" value="{{ csrf_token() }}">
But this not works, when I send my form the TokenMismatchException appears in my screen. 但这不起作用,当我发送表单时,TokenMismatchException出现在屏幕上。
This is my complete form, I don´t want use web controllers to post, I want post in self file. 这是我完整的表格,我不想使用Web控制器发布,我想发布在自我文件中。
<form method="POST" action="order.php" id="formcontacto">
<textarea name="mensaje" id="mensaje"></textarea>
<input type="hidden" name="FUNCTION" id="FUNCTION" value="creaincid" />
<button id="btn-enviar" class="btn" type="button" onclick="envia();">Enviar</button>
<input type="hidden" name="next_url" value="{{ $_SERVER['SERVER_PROTOCOL'] .'://'.$_SERVER['HTTP_HOST'] .'?'.$_SERVER['QUERY_STRING'] }}">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
</form>
I have encountered this myself and is normally something quite simple that has been over looked. 我本人也遇到过这种情况,通常看起来很简单。
First off if you are using a blade template try adding to your template 首先,如果您使用的是刀片模板,请尝试添加到模板中
{{ csrf_field() }}
More information - http://laravel.com/docs/master/routing 详细信息-http://laravel.com/docs/master/routing
This can also be an issue with with config/session.php check there isn't an issue with the domain entered here. config / session.php也可能是一个问题,请检查此处输入的域是否存在问题。
If neither of these address the issue you may need to create a middleware 如果这些都不解决问题,则您可能需要创建一个中间件
An excellent answer can be found here: Laravel 5 TokenMismatchException on PHP 5.6.9 一个很好的答案可以在这里找到: PHP 5.6.9上的Laravel 5 TokenMismatchException
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.