gpt4 book ai didi

laravel - 将 CSRF token 添加到 Laravel 表单时出错

转载 作者:行者123 更新时间:2023-12-02 11:10:15 25 4
gpt4 key购买 nike

我在 Laravel 中有一个登录表单:

<form class="form-signin" action="{{ URL::route('adminAuthen') }}" method="POST">
{{ csrf_field() }}
<h2 class="form-signin-heading">Admin Login</h2>
<label for="inputUsername" class="sr-only">Email address</label>
<input type="text" id="inputUsername" name="username" class="form-control" placeholder="Username" required autofocus>
<label for="inputPassword" class="sr-only">Password</label>
<input type="password" id="inputPassword" name="password" class="form-control" placeholder="Password" required>
<button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button>
</form>

但是当我访问这个表单时总是出现错误:

Call to undefined function csrf_field()

如何修复这个错误?

最佳答案

我认为 laravel 5 中没有名为 csrf_field() 的函数,请使用这个而不是那个。

<input type="hidden" name="_token" value="{{ csrf_token() }}">

更新2016-03-17

Laravel介绍csrf_field()版本5.1

{{ csrf_field() }} 这将生成 csrf token 字段,

关于laravel - 将 CSRF token 添加到 Laravel 表单时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30207737/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com