How to Integrate Google reCAPTCHA into website forms to avoid spam

If you created contact us form or any other form in your website, there are higher chance the online autobots filling this forms and creating spams into your inbox, to avoid this google has developed “reCAPTCHA” which allows the visitor on the form to confirm that he is a human and not robot.

For this first thing, we will need is to get keys from google website, as

1. Visit https://www.google.com/recaptcha/admin this will require you to login to your gmail account.

recaptcha

2. After login you will get a form like below, for online websites select “reCAPTCHA V2”, give identifiable Label such as your domain name without extention.

3. Enter the website domain name in “domain list, you will not need to add any sub-domains.
4. Tick for selecting “Terms” and click “Register”

On next opened page, you will get SiteKey & Secret Key.

google recaptch

The next step is to use those keys for the client and server side integration. Google Already has given a example for how to do this. Its better we will reuse those.

Download the files from https://github.com/google/recaptcha/tree/1.0.0/php

Or like,

 sudo wget -c https://raw.githubusercontent.com/google/recaptcha/1.0.0/php/recaptchalib.php 
 sudo wget -c https://raw.githubusercontent.com/google/recaptcha/1.0.0/php/example-captcha.php 

Modify Add the above keys into example-captcha.php , Now by referring to this example-captcha.php file, we will need to modify our contact-us.php.

And then upload both recaptchalib.php and our updated contact-us.php to your server.

Reference –

Google reCAPTCHA tutorial

Android Android Commands Android Java Applications Application Libraries Bash / Shell Scripts Bluetooth driver Build Frameworks Commands and Packages Core Kernel C Programs Development Environment Setup Documents / Books Errors & Failures File Systems Framebuffer / Display Driver git Go Language Programs Hardware Platforms Home JAVA Programs Kernel & Device Drivers Kernel Booting and Porting Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL NDK / Middleware / HAL Network Driver OS Concepts PHP Procfs Filesystem Programming Languages RaspberryPi Scripting and Automation Search Engine Optimisation ( SEO ) Socurce Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized Userspace Utilities Web design and development Wordpress Yocto / Bitbake / Openembedded

Leave a Reply