Easily Add reCAPTCHA to Your PHP Website

In this tutorial, I will show you how to add Google’s new reCAPTCHA to a form in your website. It was quite a few months ago Google introduced its new Captcha called reCAPTCHA. The new system in invented because some AI Softwares have proven that 99% of the text inside captchas can be extracted.

What’s Before: The old captcha works based the juggled letters and asks users to type. It’s not very secure nowadays and not user-friendly too. The program checks whether the typed words are correct for the corresponding image.


What’s New: The new “No CAPTCHA reCAPTCHA” is pretty cool. By collecting some data like mouse movements and all, Google’s algorithm finds whether it is a human or a robot. Only you have to do it click on the check box, “I’m not a robot”


How to Add reCAPTCHA to your Website’s Form

Demo Download Source Code

  1. Go to https://www.google.com/recaptcha/admin and register your site
    register site recaptcha
  2. After adding your site, you will get both site key and secret key. Note it down, we will use it in code.
    recaptcha code php
  3. Add site key to data-sitekey where the captcha box will be displayed (index.html).
  4. And finally, add a secret key to submit.php. Note that there is a library called ‘recaptchalib.php‘. You have to download the full source code from below.

Demo Download Source Code

Changing Theme of No Captcha Recaptcha

Recaptcha by default comes with a light color theme. You can also get dark theme by using the following code.

recaptcha dark theme