5 Steps to Add “No CAPTCHA reCAPTCHA” Using PHP

If you want to add google new reCAPTCHA (I’m not a robot). This captcha system is used to stop spam registrations or inquiry submissions. You can integrate this “No Captcha reCaptcha” in your website by following these simple steps.

First of all create the google reCAPTCHA access credentials, After getting site key & secret key you can add reCAPTCHA to your web page by adding simple HTML tags. Then writing PHP code to check whether we are receiving success response or not?

1. Create Google reCAPTCHA credentials

Create reCAPTCHA login credentials from google.com/recaptcha, enter label & domains. Here I’m entering my label as “localhost reCAPTCHA API” and domains localhost & codingcyber.com.

Because mostly I’m working on this file in localhost, enter your domain names and click on register button.

If you want to receive alerts select the checkbox. In my case, I don’t want to receive alerts.

2. Create Simple HTML Form

Create simple HTML form and save this with PHP file extension. Here is the code, if you want you can use this code.

3. Add “I’m not a robot captcha” to your webpage

You can get simple HTML tags after registering with google.com/recaptcha from under client side integration. You have add these two tags one is script tag and another one is simple div.

After adding these two tags, you form should look like below code sinppet.

If you reload this web page in browser you should see recaptch before submit button.

4. Include reCAPTCHA library

Create a new PHP file and add this code and save it. And using require_once PHP function include this file.

5. Adding PHP Logic to check submitted reCAPTCHA

First of all add your secret key using secret variable.
Create empty response variable.
Define new recaptcha using secret variable.
Add this below code to your webpage.

Then verify response from google recaptcha and store this in variable(this is an object). also send submitted ip address using server usper global. and recaptcha response. Add this code in your webpage.

This response object should contain success=1, check this using if condition. If the condition is true insert the data into database or execute statement based on your requirement.

Complete Code

This is the complete code of this script, if you have any problem in assembling the above pieces you can use this complete code.

If you have any problem using this code, let me know through comment form below.

Vivek Vengala
 

Vivek Vengala is a Online Entrepreneur, Web Developer from Hyderabad India.

Click Here to Leave a Comment Below 0 comments

Leave a Reply:

x

Join My Facebook Group to Receive Coding Tutorial for Free

email-subsribe