How To Add Captcha In Form
What Captcha means?
Captchas, they are a human response test. The word is actually an stands for: Completely Automated Public Turing test to tell Computers and Humans Apart.
Captcha is a verification process that requires users to enter a pre-determined code.The reasoning behind why websites implement CAPTCHA codes into their registration processes is because of spam . Those crazy letters are a way to check if the person registering or trying to comment is a real live human being as opposed to a computer program attempting to spam the site. Yes, it’s the same reason most of us have some form of spam blocker on our email.
There are many types of captchas :
- No CAPTCHA reCAPTCHA
- BotDetect CAPTCHA
- Image CAPTCHA
How to Use Captcha?
Step 1 : First of all, we use Google Recaptcha so,Registering for Google reCAPTCHA.
First, you need to go to Google reCAPTCHA panel. Click on the “Get reCAPTCHA” button on the top. Give a label to your project. Then select the type of reCAPTCHA you want to use. reCAPTCHA v2 has proven to be more successful and accepted by the developer community. So we will go with that. On the “Domain” field add the domains you want to have reCAPTCHA.for example add localhost in domain field.Now, accept the reCAPTCHA Terms of Service and click on “Register”.
Once you’ve done that, you’ll be redirected to a page showing your site key, secret key, client side and server side integration process. If not then go to Google reCAPTCHA panel and click on your project name.
For Example :
Step 3: Adding the ‘Site Key’ to the HTML form
put below code at end of form for recaptcha:
<div class="g-recaptcha" data-sitekey="This is generated in previous step ">
Step 4: Adding the ‘Secret Key’ to the PHP file.
please note that, That Recaptcha only work if put this code on htdocs folder.