CodeIgniter Forums
Help with captcha - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: Help with captcha (/showthread.php?tid=51570)



Help with captcha - El Forum - 05-09-2012

[eluser]Unknown[/eluser]
I have a comments module and I want to add captcha to the comment form. I've seen a lot of examples but cant seem to get how to do it...

Could I pls get help with the correct codes to add to the comments_view, comments_model and comments_controller file to get the captcha to work. A solution will b well appreciated.


Help with captcha - El Forum - 05-10-2012

[eluser]Unknown[/eluser]
If you download the recaptcha here: https://developers.google.com/recaptcha/docs/php

You can add the recaptcha library as a helper. Rename it to recaptchalib_helper.php and put it in your helper folder.

Edit the recaptcha function with the pub key (which you need to request here - https://www.google.com/recaptcha/admin/create):

Code:
function recaptcha_get_html ($pubkey = '{put your key in here}', $error = null, $use_ssl = false)

From there you just need to add:
Code:
echo recaptcha_get_html();

where you want the captcha displayed.

EX:
Code:
//javascriptopen
  var RecaptchaOptions = {
   theme : 'clean'
  };
  //javascript end
        <label class="ipsField_title" for="display_name">
            Security
        </label>
        <p class="ipsField_content">
            &lt;?php echo recaptcha_get_html(); ?&gt;
        </p>