gpt4 book ai didi

php - 无法访问与您在CI3中的字段名称相对应的错误消息

转载 作者:行者123 更新时间:2023-12-03 08:54:04 28 4
gpt4 key购买 nike

我检查了所有可能使我的代码出错的东西,但仍然向我显示了此错误。请帮忙 。

 Unable to access an error message corresponding to your field name Username.(check_username) 

这是我的代码如下:
 public function index()
{
if ( ! file_exists(APPPATH.'/views/login.php'))
{
/* Whoops, we don't have a page for that! */
show_404();
}
$this->load->helper('security');
$this->load->library('form_validation'); // Including Validation Library.
$this->form_validation->set_error_delimiters('<div class="error">', '</div>'); // Displaying Errors in Div
$this->form_validation->set_rules('username', 'Username', 'trim|required|xss_clean|callback_check_username'); // Validation for Username Field
$this->form_validation->set_rules('password', 'Password', 'trim|required|xss_clean'); // Validation for Password field.

if ($this->form_validation->run() == FALSE) {
$this->load->view('login');
}

function check_username($username)
{
if ($username == 'test') {
$this->form_validation->set_message('check_username','already exists.');
return false;
} else {
return TRUE;
}

}
}

最佳答案

在配置文件中执行$config['global_xss_filtering'] = TRUE;

在Codeigniter-3中,xss_filtering不是form_validation的一部分。

关于php - 无法访问与您在CI3中的字段名称相对应的错误消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31956694/

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