csrf令牌
csrf
get请求
路由
// index.php
Route::get('/', function () {
// return view('welcome');
return view('login');
});
Route::get('d3',function(Request $request){
echo "输入的内容是" . "<font color=''>".$request -> input('mytext')."</font>";
});
视图
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<form action="http://localhost/index.php/d3" method="get">
内容:<input type="text" name="mytext">
<br>
<input type="submit" value="提交" >
</form>
</body>
</html>
post
在 form 表单 中 开启 令牌
路由
// index.php
Route::get('/', function () {
// return view('welcome');
return view('login');
});
Route::post('d3',function(Request $request){
echo "输入的内容是" . "<font color='red'>".$request -> input('mytext')."</font>";
});
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<form action="http://localhost/index.php/d3" method="post">
@csrf
<!-- 上面这行就是开启令牌 -->
内容:<input type="text" name="mytext">
<br>
<input type="submit" value="提交" >
</form>
</body>
</html>
原文地址:https://blog.csdn.net/2301_80189168/article/details/143558878
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!