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>
相关推荐
颜酱4 分钟前
LLM为核,上下文为限:拆解AI Agent生态的底层逻辑
前端·人工智能
xiaoyan20157 分钟前
2026爆肝!Flutter3.41纯手撸微信聊天APP原生应用
android·flutter·dart
前端那点事7 分钟前
Vue3 超全复盘!30+前端高频核心知识点(开发+面试全覆盖)
前端·vue.js
幼儿园技术家1 小时前
为什么 SSR 一定会有 hydration mismatch?
前端
FlyWIHTSKY1 小时前
Vue 3 中 RouteRecord 详解(Vue Router 4)
前端·javascript·vue.js
yingyima1 小时前
用 cron 定时发送邮件报告:实战案例详解
前端
jinanwuhuaguo1 小时前
OpenClaw协议霸权——从 MCP 标准到意图封建化的政治经济学(第十八篇)
android·人工智能·kotlin·拓扑学·openclaw
GAMC1 小时前
从 “凭感觉写代码” 到 “按规范做开发”:OpenSpec 让 AI 编程回归工程化
前端·人工智能
微学AI1 小时前
Claude-Code-python 前端改造项目工作流程详解
开发语言·前端·python
撩得Android一次心动1 小时前
Android Room 数据库详解【源码篇】
android·数据库·android jetpack·room