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>
相关推荐
wenzhangli727 分钟前
Ooder A2UI 核心架构深度解析:WEB 拦截层的设计与实现
前端·架构
前端百草阁1 小时前
【前端性能优化全链路指南】从开发编写到构建运行的多维度实践
前端·性能优化
女生也可以敲代码1 小时前
AI时代下的50道前端开发面试题:从基础到大模型应用
前端·面试
ZhengEnCi1 小时前
M5-markconv自定义CSS样式指南 📝
前端·css·python
scan7241 小时前
长期记忆存储在数据库里
android
IT_陈寒2 小时前
SpringBoot自动配置的坑差点让我加班到天亮
前端·人工智能·后端
xingpanvip2 小时前
星盘接口开发文档:星相日历接口指南
android·开发语言·前端·css·php·lua
@PHARAOH2 小时前
WHAT - GitLens supercharged 插件
前端
TT模板2 小时前
苹果cms整合西瓜播放器XGplayer插件支持跳过片头尾
前端·html5
Wect3 小时前
React 性能优化精讲
前端·react.js·性能优化