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.
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.
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
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.