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>
相关推荐
懂懂tty7 分钟前
CRA 迁移 Rspack(实战)
前端·架构
知行合一。。。26 分钟前
Python--05--面向对象(属性,方法)
android·开发语言·python
leobertlan31 分钟前
好玩系列:用20元实现快乐保存器
android·人工智能·算法
小码哥_常1 小时前
Kotlin 助力 Android 启动“大提速”
前端
GreenTea2 小时前
AI 时代,工程师的不可替代性在哪里
前端·人工智能·后端
Jagger_2 小时前
能不能别再弄低代码害人了
前端
朦胧之2 小时前
AI 编程开发思维
前端·后端·ai编程
踩着两条虫2 小时前
VTJ:快速开始
前端·低代码·架构
木斯佳3 小时前
前端八股文面经大全:携程前端一面(2026-04-17)·面经深度解析
前端·状态模式
Java后端的Ai之路4 小时前
LangChain ReAct Agent 核心技术问答
前端·react.js·langchain