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>
相关推荐
椒盐螺丝钉19 小时前
Vue Router应用:组件跳转
前端·javascript·vue.js
顾安r19 小时前
11.20 开源APP
服务器·前端·javascript·python·css3
敲敲了个代码20 小时前
CSS 像素≠物理像素:0.5px 效果的核心密码是什么?
前端·javascript·css·学习·面试
少云清20 小时前
【软件测试】5_基础知识 _CSS
前端·css·tensorflow
倔强青铜三20 小时前
AI编程革命:React + shadcn/ui 将终结前端框架之战
前端·人工智能·ai编程
天外飞雨道沧桑21 小时前
前端开发 Cursor MCP 提效工具配置
前端·vscode·ai编程·开发工具·cursor
朱哈哈O_o21 小时前
前端通用包的作用——jquery篇
前端
葡萄城技术团队21 小时前
纯前端驱动:在线 Excel 工具的技术革新与实践方案
前端·excel
芳草萋萋鹦鹉洲哦21 小时前
【vue】调用同页面其他组件方法几种新思路
前端·javascript·vue.js
巴啦啦臭魔仙21 小时前
uniapp scroll-view自定义下拉刷新的坑
前端·javascript·uni-app