csrf令牌

csrf

get请求

路由

php 复制代码
//  index.php
Route::get('/', function () {
    // return view('welcome');
    return view('login');
});


Route::get('d3',function(Request $request){
    echo "输入的内容是" . "<font color=''>".$request -> input('mytext')."</font>";
});

视图

php 复制代码
<!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 表单 中 开启 令牌

路由

php 复制代码
//  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>";
});
php 复制代码
<!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>
相关推荐
兰亭妙微UI设计公司5 分钟前
兰亭妙微ui设计公司分享:B端组件命名如何支持团队协作
前端·javascript·vue.js
方白羽7 分钟前
Android 双开环境底层剖析与风控检测落地
android·安全·app
云和数据.ChenGuang29 分钟前
光哥说Python 异常深度解析:从异常模型到工程化实践
java·前端·人工智能·python·langchain
weixin_5633714740 分钟前
Android Studio 2024 版 Device Explorer 打开方法
android·ide·android studio
小大宇1 小时前
Vue知识点-ElementPlus-03提示框+询问+通知
前端·javascript·vue.js
步行cgn2 小时前
Axios 请求成功但页面不显示:两个前端错误的分析与修正
前端
时间的情敌2 小时前
WebGIS + OpenLayers + GeoServer + PostGIS #量算 #点聚合
前端·geoserver·openlayers
不可能片场3 小时前
Electron 发布 cookie 库先查明文再写解密
前端·electron
郭小李3 小时前
springmvc 拦截器
java·开发语言·前端
web打印社区3 小时前
Chrome-kiosk-printing能上生产吗
开发语言·前端·javascript·chrome·websocket