Codeigniter 无法访问与字段名captcha对应的错误消息。(captchacheck)
我使用了这里找到的解决方案。它在Mac上运行于我的CI 3.0,但是当我尝试将该站点部署到我的Ubuntu服务器时,它会生成“无法访问与您的域名captcha(captchacheck)对应的错误消息”。 请帮忙 谢谢Codeigniter 无法访问与字段名captcha对应的错误消息。(captchacheck),codeigniter,Codeigniter,我使用了这里找到的解决方案。它在Mac上运行于我的CI 3.0,但是当我尝试将该站点部署到我的Ubuntu服务器时,它会生成“无法访问与您的域名captcha(captchacheck)对应的错误消息”。 请帮忙 谢谢 function index(){ $this->load->library('form_validation'); $this->form_validation->set_rules('username', 'User Name', 'trim|
function index(){
$this->load->library('form_validation');
$this->form_validation->set_rules('username', 'User Name', 'trim|required|min_length[4]|xss_clean');
$this->form_validation->set_rules('firstname', 'First Name', 'trim|required|min_length[4]|xss_clean');
$this->form_validation->set_rules('lastname', 'Last Name', 'trim|required|min_length[4]|xss_clean');
$this->form_validation->set_rules('email', 'Your Email', 'trim|required|valid_email');
$this->form_validation->set_rules('password', 'Password', 'trim|required|min_length[4]|max_length[32]');
$this->form_validation->set_rules('password2', 'Password Confirmation', 'trim|required|matches[password]');
$this->form_validation->set_rules('country', 'Country', 'trim|required|min_length[4]|xss_clean');
$this->form_validation->set_rules('company', 'Company', 'trim|required|min_length[4]|xss_clean');
$this->form_validation->set_rules('captcha', 'captcha', 'trim|strip_tags|callback_captcha_check|match_captcha[captcha.word]');
$data = $this->get_data_from_post();
if ($this->form_validation->run($this) === false){
$data['image'] = $this->captcha_model->create_image();
$data['view_file'] = 'registration';
$data['js']="";
$data['module'] = 'users';
$this->load->module('template');
$this->template->site($data);
}
else{
$data2 = $this->get_data_from_post();
$this->db->insert('ict_users',$data2);
$data['view_file'] = 'success';
$data['js']="";
$data['module'] = 'users';
$this->load->module('template');
$this->template->site($data);
}
}
function captcha_check($value){
if($value==''){
$this->form_validation->set_message('captcha_check','Please enter the text from the image');
return false;
}
else{
return true;
}
}
@user1372324我忘了提到我已经扩展了表单验证,我在该类中包含了match_captcha函数:den try put$this->form_validation->set_message('captcha_check','Please enter the text from the image');下面$this->form_validation->set_rules('captcha','captcha','trim | strip_tags | callback | captcha_check | match_captcha[captcha.word]);
Please remove
match_captcha[captcha.word]
You need to use a callback for it below given
public function validate_captcha(){
if($this->input->post('captcha') != $this->session->userdata['captcha'])
{
$this->form_validation->set_message('validate_captcha', 'Wrong captcha code, hmm are you the Terminator?');
return false;
}else{
return true;
}
}