我想在 Laravel 中进行基本的登录/注销。所以我在resources/views
名为auth下创建了一个新文件夹,然后我创建了一个新文件,login.blade.php
将其插入其中:
<html>
<body>
<form>
<input type="text" name="email" placeholder="email" size="40"><br><br>
<input type="password" name="password" placeholder="password" size="40"><br><br>
<input hidden name="_token" value="{{csrf_token}}">
<input type="submit" value="send">
</form>
</body>
</html>
之后,我像这样编辑了 web.php:
Route::get('/', function () {
return view('welcome'); });
Route::get('/home', function () {
return view('welcome'); });
Route::get('/login', function () {
return view('auth.login'); });
Route::post('/login','Auth\LoginController@login');
Route::post('/logout','Auth\LoginController@logout');
所以它应该可以正常工作,因为一切都有意义,但是每当我转到登录 url 时,我都会看到以下错误消息:
ErrorException in 6c95db2d362954448afd30aa9a2bf2cb0fc31937.php 第 6 行:未定义常量 csrf_token 的使用 - 假定为“csrf_token”(视图:G:\xampp\htdocs\o2architect\rootresourcethlara\php
所以谁能告诉我这里发生了什么?!
更改:
<input hidden name="_token" value="{{csrf_token}}">
至
<input hidden name="_token" value="{{ csrf_token() }}">
然后再试一次。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句