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=''></script>
  if(isset($_POST['sendEmail'])) {
    $privateKey = "__my_secret_key__";
    $response = $_POST['g-recaptcha-response'];
    $remoteip = $_SERVER['REMOTE_ADDR'];
    $url = file_get_contents("$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,

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


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;
         document.getElementById('captcha').innerHTML="Captcha completed";
        return true; 


6 thoughts on “How to add google recaptcha in html form”

Leave a Comment