提交表单报400错误,提示 “您提交的数据无法验证”
原来是csrf验证的问题,因为表单是自己写的,在Yii框架中,为了防止csrf攻击,对post的表单数据封装了CSRF令牌验证。
解决办法关闭csrf验证

frontend/config/main-local.PHP

在配置文件中关闭

$config = [
    'components' => [
        'request' => [
            // !!! insert a secret key in the following (if it is empty) - RG2V-Dz_PXVhz7GUtKtbhjIcZ3JPmXaTthis is required by cookie validation
            'cookieValidationKey' => 'my-first-yii-web-frontend',
            "enableCsrfValidation"=>false,
        ],
    ],
];

只需要加入"enableCsrfValidation"=>false,就可以了

 

相关文章:

  • 2021-09-29
  • 2022-12-23
  • 2021-05-24
  • 2022-12-23
  • 2021-12-17
  • 2022-02-01
  • 2021-05-15
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-02-15
  • 2022-12-23
  • 2021-12-01
  • 2022-12-23
  • 2021-08-10
  • 2022-01-14
相关资源
相似解决方案