How to Add Google reCAPTCHA in PHP form

This is a really quick tutorial to add Google reCAPTCHA in a PHP form. reCAPTCHA is used to prevent spam or autonomous illegal activities on your website, which can result in overuse of the bandwidth of your server fill your databases with junk data.

Here we will discuss v2 of Google reCAPTCHA.

Let’s get started…

Also Check: Add reCAPTCHA v2 and Form Validation using Custom jQuery

Step 1) Go to Google reCAPTCHA , then click on “My reCAPTCHA” after sign up, then Add a label, select the first option “reCAPTCHA v2” add your site URL then click on Register


Step 2) Next screen will show your “Site key” and “Secret key” keep them safe, we will need it later.


Step 3) Now go to this URL to download the source code, in downloaded zip upload “src” folder to your same server with form page.

Step 4) Open form.php which will have your form and reCAPTCHA code. Now add below javascript file in your form.php ‘s head section

Add below HTML from Step 2) in your form where you want to show reCAPTCHA

Then add this PHP code in head section of form.php

Add “site key” and “secret key” in above code from step 2

Now Complete HTML of form.php will look like this



Leave a Reply

Notify of