[eluser]vile[/eluser]
i followed the steps in recaptcha codeigniter wiki.
it seems that validation->set_message doesnt work. here's the validation message "Unable to access an error message corresponding to your field name."
here's my code:
controller:
Code:
function signup(){
$data = array();
print_r($_POST);
$data = array('captcha' => $this->recaptcha->recaptcha_get_html());
$data['message'] = "";
//form validation
$this->form_validation->set_rules('firstname', 'firstname', 'required|required|min_length[3]|alpha|trim');
$this->form_validation->set_rules('lastname', 'lastname', 'required|min_length[3]|alpha|trim');
$this->form_validation->set_rules('email', 'email', 'required|valid_email|trim');
$this->form_validation->set_rules('gender', 'gender', 'required');
$this->form_validation->set_rules('day', 'day', 'required');
$this->form_validation->set_rules('month', 'month', 'required');
$this->form_validation->set_rules('year', 'year', 'required');
$this->form_validation->set_rules('password', 'password', 'required|matches[passwordconf]|min_length[6]|trim|md5');
$this->form_validation->set_rules('passwordconf', 'password confirmation', 'required');
$this->form_validation->set_rules('recaptcha_response_field', 'captcha', 'required|callback_check_captcha');
if ($this->form_validation->run() == FALSE)
{
//set custom message
$this->form_validation->set_message('firstname', 'You must enter your first name.');
$this->form_validation->set_message('lastname', 'You must enter your last name.');
$this->form_validation->set_message('gender', 'You must select your gender.');
$this->form_validation->set_message('email', 'Sorry. Invalid email address. Please use your real email address..');
$this->load->view('signupForm',$data);
}
else
{
$data = $this->mainmodel->process_signup();
if($data['queryresult']){
$this->load->view('signupsuccess',$data);
}else{
$this->load->view('signupForm',$data);
}
}
}
function check_captcha($val) {
$this->recaptcha->recaptcha_check_answer($_SERVER["REMOTE_ADDR"],$this->input->post('recaptcha_challenge_field'),$val);
if ($this->recaptcha->is_valid) {
return true;
} else {
$this->form_validation->set_message('recaptcha_response_field','Incorrect Security Image Response');
return false;
}
}
btw my custom message wont work too. can you please tell what i did wrong? i been stuck here fo a while. thanks for your help