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>
相关推荐
拿不拿铁193 分钟前
Vite 5.x 开发模式启动流程分析
前端
fruge12 分钟前
设计稿还原技巧:解决间距、阴影、字体适配的细节问题
前端·css
油炸小波28 分钟前
09-微服务原理篇(XXLJOB-幂等-MySQL)
android·mysql·微服务
BBB努力学习程序设计33 分钟前
了解响应式Web设计:viewport网页可视区域
前端·html
zhangyao94033035 分钟前
uni-app scroll-view特定情况下运用
前端·javascript·uni-app
码农张36 分钟前
从原理到实践,吃透 Lit 响应式系统的核心逻辑
前端
jump68036 分钟前
object和map 和 WeakMap 的区别
前端
打小就很皮...42 分钟前
基于 Dify 实现 AI 流式对话:组件设计思路(React)
前端·react.js·dify·流式对话
果子没有六分钟44 分钟前
setprop debug.hwui.profile visual_bars有什么作用
android
这个昵称也不能用吗?1 小时前
【安卓 - 小组件 - app进程与桌面进程】
前端