How to add google recaptcha in html form

How to add google Recaptcha in Html form. For this, you need to visit the Recaptcha website. You have to create an account and bring some documents from that khan. This document is also different for each website. Once you have entered the document, you can add your website Recaptcha to the code below. Read More

reCAPTCHA All version Html add system is the same. If you can learn how to add any reCAPTCHA. You can add any reCAPTCHA on the Html page Google owns the reCAPTCHA about us page is very nicely discussed.

code example

<script src='https://www.google.com/recaptcha/api.js'></script>
<?php
  if(isset($_POST['sendEmail'])) {
    $privateKey = "__my_secret_key__";
    $response = $_POST['g-recaptcha-response'];
    $remoteip = $_SERVER['REMOTE_ADDR'];
    $url = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=$privateKey&response=$response&remoteip=$remoteip");

    $result = json_decode($url, true);

    if($result->success == true) {
      $name = strip_tags(trim($_POST['name_1']));
      $surname = strip_tags(trim($_POST['surname_1']));
      $userArray = [
        'name' => $name,
        'surname' => $surname,
      ];
      var_dump($userArray);

    } else {
      echo "reCaptcha failed, please try again...";
    }
  }

?>
<script>

function get_action(form) 
{
    var v = grecaptcha.getResponse();
    if(v.length == 0)
    {
        document.getElementById('captcha').innerHTML="You can't leave Captcha Code empty";
        return false;
    }
    else
    {
         document.getElementById('captcha').innerHTML="Captcha completed";
        return true; 
    }
}

</script>

Related Posts

meter element

meter element

How To Use The Meter Element In HTML?

Preg_match_all-in-php.jpg

Preg_match_all in php

The Basic Concept of the PHP preg_match_all Function The PHP preg_match_all function is a pattern-matching function that matches the text. This function is use to search for…

document.queryselector-in-javascript.jpg

what is document.queryselector in javascript

What is document.querySelector() in Javascript? The javascript document.querySelector() method retrieves. The element with the given tag name or id from within a document. The document.querySelector() method returns…

JQuery hide Method.jpg

JQuery hide Method

What can the JQuery Hide Method Do For You? The JQuery Hide Method is a function that one can use to hide text on a website. It…

Push array in php.jpg

Push array in php

What is a php Push Array? A push array is a PHP data type that can store an arbitrary number of values. The push array is a…

How to use map method in javascript.jpg

How to use map method in javascript

What is the Map Method? The map method is a higher-order function in JavaScript. Who can use it to transform an array into another array by iterating…

This Post Has 6 Comments

Leave a Reply

Your email address will not be published.

Education Template