Implementing reCAPTCHA in CI |
[eluser]Unknown[/eluser]
Hello all, I intend this as a guide to those struggling to add reCAPTCHA to CI. Here's how I was able to do it: 1. After registering, I downloaded the reCAPTCHA PHP library at http://code.google.com/p/recaptcha/downl...lib-Latest. 2. I renamed recaptchalib.php in that ZIP file to recaptcha_helper.php and dropped it in my application/helpers directory. 3. I used this code in my view (replacing Code: PUBLIC_KEY Code: $CI =& get_instance(); (Obviously if you're loading this in a controller or model, the top two $CI lines can be replaced with Code: $this->load->helper('recaptcha'); 4. In the validation method of my controller, I added this code (replacing Code: PRIVATE_KEY Code: $this->load->helper('recaptcha'); That's it! So far it seems to be working. Hope this helps!
[eluser]tkyy[/eluser]
i find the best way to implement recaptcha is to actually do a curl call to the noscript version of the page (using your public key as the get parameter) and then parsing the challenge id out of the text. you then display the challenge id using the recaptcha url to get images (the parameter in that url is "c="). this way you can avoid having a ton of crappy "powered by recaptcha" images all over your page and you can display the image itself in any way you see fit. make sure to store the challenge id as a hidden variable and pass it to your form submission function for validating. here is an exact example of how i do it on a live social networking site Code: //grab the recaptcha page i find this is better like i said because you can manipulate it anyway you want. |
Welcome Guest, Not a member yet? Register Sign In |