Codeigniter 3无法访问错误消息 [英] Codeigniter 3 Unable to access an error message

查看:163
本文介绍了Codeigniter 3无法访问错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Codeigniter 3中有set_rules函数的问题

I have proble with set_rules function in Codeigniter 3

我检查用户电子邮件:

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

,当我发布时会收到此错误:

and when I post get this error:

无法访问与您的字段名称电子邮件相对应的错误消息。

推荐答案

github:


一个关于XSS清理的基本上未知的规则是它应该只是
应用于输出,而不是输入数据。

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

我们使用自动和全局XSS
清除功能犯了这个错误(参见上面关于XSS的上一步),所以现在在
努力阻止这种做法,我们也从正式支持的表单验证规则列表中删除了'xss_clean'

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.

因为表单验证库一般验证输入数据,
'xss_clean'规则根本不属于它。

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

,真的需要应用该规则,您现在还应该
加载安全助手
,其中包含xss_clean()作为常规函数,因此也可以用作验证规则。

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-the-the-the-xss_clean-form-validation-rule

你真的需要它,去应用程序/ config / autoload.php:

And if, despite everything, you really need it, go to application/config/autoload.php :

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

或在表单验证之前

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

这篇关于Codeigniter 3无法访问错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆