CodeIgniter - 无法访问对应于您的字段名称的错误消息密码。(pword_check) [英] CodeIgniter - Unable to access an error message corresponding to your field name Password.(pword_check)
问题描述
我是codeIgniter的新手,我刚刚陷入了一开始。我使用HMVC扩展,并在验证时收到以下错误:
I am a new to codeIgniter and I just got stuck in the very beginning. I am using HMVC extention and while validating I am getting the following error:
无法访问与您的字段名称密码对应的错误消息(pword_check)
任何帮助将非常感谢。
代码:
public function submit()
{
$this->load->library('form_validation');
$this->form_validation->set_rules('username', 'Username', 'required|max_length[30]|xss_clean');
$this->form_validation->set_rules('pword', 'Password', 'required|max_length[30]|callback_pword_check|xss_clean');
if ($this->form_validation->run() == FALSE)
{
$this->login();
}
else
{
echo 'Success'; die();
}
}
public function pword_check($str)
{
if ($str == 'test')
{
$this->form_validation->set_message('pword_check', 'The %s field can not be the word "test"');
return FALSE;
}
else
{
return TRUE;
}
}
推荐答案
xss_clean不再是Codeingitore 3中表单验证的一部分
xss_clean is no longer part of form validation in Codeingitore 3
只需删除 xss_clean
从您的验证roul
Just remove xss_clean
from your validation roul
$this->form_validation->set_rules('pword', 'Password', 'required|max_length[30]|callback_pword_check');
如果你真的需要应用这个规则,你现在还应该加载安全助手包含 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.
code> application / config / autoload.php:
go to application/config/autoload.php :
$autoload['helper'] = array('security');
或在表单验证之前
$this->load->helper('security');
这篇关于CodeIgniter - 无法访问对应于您的字段名称的错误消息密码。(pword_check)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!