[英]@csrf is not working in Laravel 5.4
I am following this tutorial on Laravel and I've noticed that I cannot use the @csrf command, but others can use it effectively.我正在关注 Laravel 上的本教程,我注意到我无法使用 @csrf 命令,但其他人可以有效地使用它。 But, I can use the {{ csrf_field() }} for the csrf token.
但是,我可以使用 {{ csrf_field() }} 作为 csrf 令牌。 I would like to know the reason why.
我想知道原因。 Thanks.
谢谢。
Here's my screenshot on using the @csrf command: Image here这是我使用 @csrf 命令的屏幕截图:这里的图片
Here's my index.blade.php这是我的 index.blade.php
<form action="{{ route('contact.store') }}" method="post">
@csrf
<div class="col-md-6 mb-3">
<label for="username">Username:</label>
<input class="form-control" type="text" name="name" id="username" placeholder="Username | Email | Phone Number" required>
<div class="invalid-feedback">
Please provide a username
</div>
</div>
<div class="col-md-6 mb-3">
<label for="password">Password:</label>
<input class="form-control" type="password" name="name" id="password" placeholder="" required>
<div class="invalid-feedback">
Please provide a password
</div>
</div>
<div class="col-md-6 mb-3">
<input type="submit">
</div>
</form>
As far as I know, there is no @csrf in 5.4, you must use据我所知,5.4中没有@csrf,你必须使用
{{ csrf_field() }}
Instead, @csrf is available in laravel 5.6相反,@csrf 在 laravel 5.6 中可用
Laravel 5.4 only available refer to this link https://laravel.com/docs/5.4/csrf仅 Laravel 5.4 可用,请参阅此链接https://laravel.com/docs/5.4/csrf
{{ csrf_field() }}
And Laravel 5.6 available refer to this link https://laravel.com/docs/5.6/csrf和 Laravel 5.6 可用参考此链接https://laravel.com/docs/5.6/csrf
@csrf
if you used to laravel framework version 5.6, 5.5 or less than version 5.5 you should write {{ csrf_field() }}
, but if you used to laravel framework version 5.7, 5.8
or bigger than version 5.7 you should write @csrf
如果你习惯laravel框架5.6版,5.5或小于5.5的版本,你应该写
{{ csrf_field() }}
但如果你使用laravel Framework版本5.7, 5.8
或大于5.7的版本,你应该写@csrf
Laravel 5.5, 5.6 => write {{ csrf_field() }}
Laravel 5.5, 5.6 => 写 {{ csrf_field() }}
Laravel 5.7, or bigger than 5.7 => write @csrf
Laravel 5.7,或大于 5.7 => 写@csrf
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.