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>
相关推荐
牛奶2 小时前
AI辅助开发最佳实践:2026年新方法
前端·aigc·ai编程
C澒3 小时前
微前端容器标准化:公共能力标准化
前端·架构
mygljx3 小时前
【MySQL 的 ONLY_FULL_GROUP_BY 模式】
android·数据库·mysql
Setsuna_F_Seiei3 小时前
AI 对话应用之 JS 的流式接口数据处理
前端·javascript·ai编程
青柠代码录4 小时前
【Vue3】Vue Router 4 路由全解
前端·vue.js
无限大64 小时前
《AI观,观AI》:专栏总结+答疑|吃透核心,解决你用AI的所有困惑
前端·后端
蜡台5 小时前
element-ui 2 el-tree 内容超长滚动条不显示问题
前端·vue.js·elementui·el-tree·v-deep
冬奇Lab5 小时前
AudioTrack音频播放流程深度解析
android·音视频开发·源码阅读
小小小小宇6 小时前
软键盘常见问题(二)
前端
小小小小宇7 小时前
软键盘常见问题
前端