Integrate Google reCaptcha in Codeigniter

reCaptcha is a user validation service that is provided by Google for free. Today we Integrate Google reCaptcha in Codeigniter signup form.

Here you also learn how to use google recaptcha on Codeigniter, completely.

The main purpose of this topic to prevent the signups from the bot. Before we start the integration of reCaptcha, first we have to know that what is the reCaptcha service and how that is worked for our website.

What is Google reCaptcha Service

That’s not a great question because Google can’t show their algorithm publically. Here are such points that how Google’s reCaptcha work and how secure that is! Check out below points,

  1. Google not check limited things, means when user check on google reCaptcha than google check that user’s activity like what he/she is serched for and check their mails and activity on the web.
  2. Also they detect your computer or system’s IP address and check on past are you using same IP like normal human do.
  3. If both above points are satisfactory than google’s reCaptcha skip their image varification.
  4. On the otherside, if google can’t find these things, that can be more suspecious of Google reCaptcha validation and also showing image varification.
  5. Also used for codeigniter recaptcha form validation or codeigniter captcha. Which is also formed as “i am not robot captcha in codeigniter”.

Integrate Google reCaptcha in Codeigniter

I hope the above points are cleared to know about Google’s reCaptcha.
Codeigniter google recaptcha validation used to prevent bot or forgery data. Also used with version codeigniter 2 captcha.
Now we start the Integration of Google reCaptcha in Codeigniter, below are simple steps to integrating google reCaptcha,

  • Registering website domain on Google reCaptcha service.
  • Go to the Codeigniter config directory and set the keys.
  • After configuartion, creating controller.
  • Than at last we craete a view file on view Dir.

So lets we start with our first point,

Explanation of Integrate Google reCaptcha in Codeigniter

Registering website domain on Google reCaptcha

Go to reCAPTCHA: Easy on Humans, Hard on Bots – Google and click on Admin Console on the top right. After that, you can see the screen like below,

Also, you can use this source as a google recaptcha example in Codeigniter.

Integrate Google reCaptcha in Codeigniter

Click on the highlighted plus (+) icon, then you go to the next step,

Integrate Google reCaptcha in Codeigniter

On there fill those things listed below,

  1. Label
  2. reCaptcha type
  3. Domain (Where you want to set the captcha)
  4. Your Email
  5. Check the “Accept the reCaptcha Terms of Service”

Then hit the Submit button. After filling and submitting the details above mentioned you can see the next screen like below,

Integrate Google reCaptcha in Codeigniter

From here you can get site key and secret key which is used for configuration in Codeigniter website. So copy both the keys from here.

Setting the Key on Config File

In Codeigniter config file stored at,

/application/config/config.php

Set the keys like that,

Creating Controller for reCaptcha

/application/controllers/User.php

Main source code

 Example of a function that how you integrate the above code in the function,

Creating a View File

application/views/users/signup.php

After the completing form fields write below code,

Now all the things or setup of Google reCaptcha in Codeigniter is completed.

Result:

Integrate Google reCaptcha in Codeigniter

Here is the complete source code to Integrate Google reCaptcha in Codeigniter.

Also check:

Happy Coding..!

Was this article helpful?
YesNo

By Bikash

My name is Bikash Kr. Panda. I own and operate PHPCODER.TECH. I am a web Programmer by profession and working on more than 50 projects to date. Currently I am working on the web-based project and all the CMS and frameworks which are based on PHP.

4 thoughts on “Integrate Google reCaptcha in Codeigniter”

Leave a Reply

Your email address will not be published. Required fields are marked *