Welcome Guest, Not a member yet? Register   Sign In
Easy reCaptcha library
#1

[eluser]GabrielGem[/eluser]
Hi! This is my library for easy reCaptcha installation for CI.

How to use Easy reCaptcha library for Codeigniter:

1) First of all, register at the reCaptcha by Google:
http://www.google.com/recaptcha
Press button "USE reCAPTCHA ON YOUR SITE", then "SIGN UP NOW" and fill the data about your site.
Then reCaptcha will generate for you 2 keys: Public Key and Private Key. Do not lose these keys!;
2) Put "recaptcha.php" library to the application/libraries folder of codeigniter;
3) Open your controller and put these code (don't forget insert your PUBLIC KEY, that was generated above):

CODE:
Code:
$publickey= "YOUR PUBLIC KEY";
          $this->load->library('recaptcha');
          $data = $this->recaptcha->recaptcha_get_html($publickey);

EXAMPLE:
Controller
Code:
$publickey= "YOUR PUBLIC KEY";
          $this->load->library('recaptcha');
          $data['recaptcha'] = $this->recaptcha->recaptcha_get_html($publickey);
$this->load->view('login',$data);

View
Code:
<form method="post" action="controller">
<?php echo $recaptcha;?>
        <input type="submit" />
      </form>


VIA VIEW. You can also realize that via view
CODE:
Code:
<?php
$publickey= "YOUR PUBLIC KEY";
$CI =& get_instance();
    $CI->load->library('recaptcha');
    echo $CI->recaptcha->recaptcha_get_html($publickey);
?>

EXAMPLE:

Code:
<form method="post" action="controller">
  <?php
   $publickey= "YOUR PUBLIC KEY";
   $CI =& get_instance();
   $CI->load->library('recaptcha');
   echo $CI->recaptcha->recaptcha_get_html($publickey);
   ?>
        <input type="submit" />
      </form>

4) Open your controller (ACTION attribute of form above) and paste these code (don't forget replace YOUR PRIVATE KEY with your new generated key):

CODE:
Code:
$this->load->library('recaptcha');
$privatekey = "YOUR PRIVATE KEY";
$response = $this->recaptcha->recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);

  if (!$response) {
/// WRONG ANSWER
  } else {
/// CORRECT ANSWER
   }

#2

[eluser]cPage[/eluser]
Code:
Fatal error: Class 'ReCaptchaResponse' not found in C:\wamp\www\ggci_2013-01-20_current\application\libraries\recaptcha.php on line 88

Where is the missing class ?

Code:
$recaptcha_response = new ReCaptchaResponse();
#3

[eluser]wr5aw[/eluser]
I use it as a helper. I just dropped it in the helper folder as is and named it captcha_helper.php. You only have to call two functions to use it.
#4

[eluser]quickshiftin[/eluser]
Nice work!




Theme © iAndrew 2016 - Forum software by © MyBB