1 Answers
Best Answer
function validate_captcha() {
$captcha = $this->input->post(‘g-recaptcha-response’);
$response = file_get_contents(“https://www.google.com/recaptcha/api/siteverify?secret=you_site_key&response=” . $captcha . “&remoteip=” . $_SERVER[‘REMOTE_ADDR’]);
if ($response . ‘success’ == false) {
return FALSE;
} else {
return TRUE;
}
}
function formSubmit() {
if(isset($_POST)){
$this->form_validation->set_rules(‘g-recaptcha-response’, ‘recaptcha validation’, ‘required|callback_validate_captcha’);
$this->form_validation->set_message(‘validate_captcha’, ‘Please check the the captcha’);
}
}
Your Answer