gpt4 book ai didi

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

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

我有一个 check_captcha 回调函数,它查看 $row==0 还是 == 1(从sql)。

问题是我不能从 $self->form_validation->set_rule('captcha', 'call_back_check_captcha') 调用它,因为我的函数需要一个 $row 变量。我现在调用它的方式是我收到无法访问错误消息。我怎样才能做到这一点?

function check_captcha( $row)
{
if($row ==0)//didnt find any
{
$this->form_validation->set_message('captcha', 'text dont match captcha');
return FALSE;
}
else
{
return TRUE;
}
}


function create_member()
{

$past = time() - 7200;

$this->db->query("DELETE FROM captcha WHERE captcha_time <".$past);
$sql = "SELECT COUNT(*) AS count FROM captcha WHERE word =? AND ip_address =?";
$binds = array($_POST['captcha'], $this->input->ip_address(), $past);
$query= $this->db->query($sql, $binds);

$row = $query->row(); //row query rows : if it found an entry =1

$self->check_captcha($row->count);

//VALIDATIONS
$this->form_validation->set_rules('first_name', 'First Name', 'trim|required');
$this->form_validation->set_rules('last_name', 'Last Name', 'trim|required');
$this->form_validation->set_rules( 'email_address', 'Email Address', 'trim|required|valid_email|unique[user.email_address]');
$this->form_validation->set_rules('username', 'Username', 'trim|required|min_length[4]|unique[user.username]');
$this->form_validation->set_rules('password', 'Password', 'trim|required|min_length[4]|max_leng[32]');
$this->form_validation->set_rules('password2', 'Password Confirmation','trim|required|matches[password]');
if(!$_POST['captcha']){
$this->form_validation->set_rules('captcha', 'Captcha','trim|required');}else{
$this->form_validation->set_rules('captcha', 'Captcha', 'callback_check_captcha');}

if($this->form_validation->run()==FALSE)
{ //this -> to the curr obj(UserController) && registraion() points to the the function in controller
$this->registration(); //reloads reg page so they can fill out right stuff
}
else

最佳答案

$this->form_validation->set_message('check_captcha', 'text dont match captcha');

消息名称对应于函数,而不是字段。因此将其设置为“check_captcha”将修复您的错误。错误消息将使用正确的字段名称。

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

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