[eluser]mariowarner[/eluser]
Thanks, man!
It still won't work so I did a different hack.
I retained the original format of the callback function because it works on my local machine (in case the issue is not with CI but on the server configurations:
Code:
function cinputCheck($str)
{
if ($str != $_SESSION["pass"]) {
$this->validation->set_message('cinputCheck', 'Incorrect Captcha characters.');
return FALSE;
}
else
{
return TRUE;
}
}
And then I did a string search for the error message generated by Validation Class in case it can't find an error message (this only works well with my codes because I know for sure that there's only one error that generates that error message):
Code:
// set validation rules
$rules['cinput'] = "required|callback_cinput_check";
$rules['email1'] = "required|valid_email";
$rules['email2'] = "required|valid_email|matches[email1]";
$this->validation->set_rules($rules);
if ($this->validation->run() == FALSE) {
$data['success'] = "0";
if($this->validation->error_string) {
$data['message'] .= '<br />Error(s): ';
}
$data['message'] .= $this->validation->error_string;
$reg_ex = 'Unable to access an error message corresponding to your field name.';
$str = $data['message'];
// i only used this because i know for sure that the $reg_ex message only shows up
// when i get to the Captcha callback function.
if (strpos($str, $reg_ex) !== false) {
$data['message'] = str_replace('Unable to access an error message
corresponding to your field name.',
'The characters you typed did not match the characters on the box.', $str);
}
$this->load->view('prelaunch', $data);
}
else {
// no more errors, proceed with the success methods
}
Again, it might not work well with bigger forms with more than one callback function (cos i think the error has to do with Validation Class' callback functions), but it did the trick for now.