gpt4 book ai didi

php - Codeigniter 3 无法访问错误消息

转载 作者:IT王子 更新时间:2023-10-28 23:50:35 24 4
gpt4 key购买 nike

我对 Codeigniter 3 中的 set_rules 函数有疑问

我检查用户邮箱:

$this->form_validation->set_rules('email', 'Email', 'required|trim|xss_clean|valid_email');

当我发帖时得到这个错误:

无法访问与您的字段名称 Email 对应的错误消息。

最佳答案

来自 codeigniter github:

A largely unknown rule about XSS cleaning is that it should only be applied to output, as opposed to input data.

We've made that mistake ourselves with our automatic and global XSS cleaning feature (see previous step about XSS above), so now in an effort to discourage that practice, we're also removing 'xss_clean' from the officially supported list of form validation rules.

Because the Form Validation library generally validates input data, the 'xss_clean' rule simply doesn't belong in it.

If you really, really need to apply that rule, you should now also load the Security Helper, which contains xss_clean() as a regular function and therefore can be also used as a validation rule.

链接:https://github.com/bcit-ci/CodeIgniter/blob/develop/user_guide_src/source/installation/upgrade_300.rst#step-13-check-for-usage-of-the-xss_clean-form-validation-rule

如果尽管如此,您确实需要它,请转到 application/config/autoload.php :

$autoload['helper'] = array('security');

或者,在您的表单验证之前

$this->load->helper('security');

关于php - Codeigniter 3 无法访问错误消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28568871/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com