Google No CAPTCHA ReCAPTCHA Using PHP

google no captcha recaptcha using php

Google No CAPTCHA ReCAPTCHA Using PHP

 |   |  0
PHP Programming

How to do Google No CAPTCHA reCAPTCHA using PHP code? Google is there to protect us from spam by new reCAPTCHA model. The new model can verify spam or not by just using a checkbox. Now users don’t have to read the scary text and fill text boxes. The new reCAPTCHA model is called as “No CAPTCHA reCAPTCHA”. The new model is more user friendly and secure.

What is reCAPTCHA?

reCAPTCHA is a free service that protects your website from spam and abuse. reCAPTCHA uses an advanced risk analysis engine and adaptive CAPTCHAs to keep automated software from engaging in abusive activities on your site. It does this while letting your valid users pass through with ease.

reCAPTCHA offers more than just spam protection. Every time our CAPTCHAs are solved, that human effort helps digitize text, annotate images, and build machine learning datasets. This in turn helps preserve books, improve maps, and solve hard AI problems.

reCAPTCHA is built for security. Armed with state of the art technology, it always stays at the forefront of spam and abuse fighting trends. reCAPTCHA is on guard for you, so you can rest easy.

Registering and Retrieving Keys

To use this feature of Google or to integrate the new reCAPTCHA in your website forms first register your site and retrieve reCAPTCHA client and secret keys.

Integration

Integrating it is very easy. Here is a PHP code example of integrating in your forms.

<!doctype html>
<html>
  <head>
    <script src='https://www.google.com/recaptcha/api.js'></script>
  </head>
 
  <body>        
    <form method="post" action="index.php">
      <div class="g-recaptcha" data-sitekey="YOUR SITE KEY"></div>
      <input type="submit" />
    </form>
  </body>
</html>
if($_SERVER["REQUEST_METHOD"] === "POST") { 
  //form submitted 
  //check if other form details are correct 
  //verify captcha 
  $recaptcha_secret = "YOUR SECRET KEY"; 
  $response = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$recaptcha_secret."&response=".$_POST['g-recaptcha-response']); 
  $response = json_decode($response, true); 
 
  if($response["success"] === true) { 
  //valid submission 
  }
} 

Done..!


1 Claps

Show your love in the form of Claps and Comments...

Comments...

No comments found. Leave your reply here.