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 分钟前
Java7新特性:try-with-resources写法
java·前端·javascript·jdk·新特性·jdk7
似霰24 分钟前
Unix Domain Socket —— UDP 篇
android·unix
fyakm35 分钟前
防范HTTP安全风险:CSRF、XSS等攻击与防御策略(含代码)
安全·http·csrf
SailingCoder1 小时前
【 从“打补丁“到“换思路“ 】一次企业级 AI Agent 的架构拐点
大数据·前端·人工智能·面试·架构·agent
~央千澈~2 小时前
抖音弹幕游戏开发之第12集:添加冷却时间机制·优雅草云桧·卓伊凡
java·服务器·前端
CappuccinoRose2 小时前
CSS 语法学习文档(十三)
前端·css·学习·postcss·模块化·预处理器
OpenTiny社区2 小时前
Angular Module→Standalone 架构进化解析
前端·架构·angular.js
独自破碎E2 小时前
BISHI54货物堆放
android·java·开发语言
冬奇Lab2 小时前
属性系统与系统配置管理:Android的全局配置中心
android·源码阅读
哆啦A梦15882 小时前
Vue3魔法手册 作者 张天禹 06_监控
前端·vue.js·typescript