Welcome Guest, Not a member yet? Register   Sign In
reCAPTCHA helper and validation function (easy-to-use captcha)
#10

[eluser]Tobz[/eluser]
I've made changes to make this work in CI 1.7.x

First, rename MY_Validation.php to MY_Form_validation.php

then change the code to match this:
Code:
<?php
if (!defined('BASEPATH')) exit ('No direct script access allowed');

class MY_Form_validation extends CI_Form_validation {

  function MY_Form_validation() {
    parent::CI_Form_validation();
  }

  function recaptcha_matches() {
    $CI = & get_instance();
    $CI->config->load('recaptcha');
    $public_key = $CI->config->item('recaptcha_public_key');
    $private_key = $CI->config->item('recaptcha_private_key');
    $response_field = $CI->input->post('recaptcha_response_field');
    $challenge_field = $CI->input->post('recaptcha_challenge_field');
    $response = recaptcha_check_answer($private_key, $_SERVER['REMOTE_ADDR'], $challenge_field, $response_field);
    
    if ($response->is_valid) {
      return TRUE;
    }
    else {
      $this->recaptcha_error = $response->error;
      $this->set_message('recaptcha_matches', 'The %s is incorrect. Please try again.');
      return FALSE;
    }
  }

}

and thats it.
Your recapture should now work with the current form validation class.


Messages In This Thread
reCAPTCHA helper and validation function (easy-to-use captcha) - by El Forum - 07-02-2009, 04:57 PM



Theme © iAndrew 2016 - Forum software by © MyBB