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>
相关推荐
Codebee3 分钟前
# 🔥A2UI封神!元数据驱动的AI交互新范式,技术人必看
前端·架构
xuyin12049 分钟前
Android内存优化
android
jzlhll12310 分钟前
android kotlinx.serialization用法和封装全解
android
JarvanMo11 分钟前
展望 2030 年:移动开发者的未来将如何?
前端
我的xiaodoujiao12 分钟前
使用 Python 语言 从 0 到 1 搭建完整 Web UI自动化测试学习系列 34--基础知识 9--文件上传功能
前端·python·测试工具·ui·pytest
辛-夷12 分钟前
pinia与Vuex高频面试题
前端·vue.js
龚子亦17 分钟前
【Unity开发】安卓应用开发中,用户进行权限请求
android·unity·安卓权限
.生产的驴21 分钟前
泛微E10二开 前端Ecode拦截器
前端
亿元程序员26 分钟前
PinK(Cocos4.0?)生成飞机大战,抢先体验全流程!
前端
晓得迷路了30 分钟前
栗子前端技术周刊第 111 期 - Next.js 16.1、pnpm 10.26、Bun 1.3.5...
前端·javascript·bun