title: CAPTCHA integration into existing PHP form
body: <p>Im using Google Recaptcha, and I've ended up with this piece of code. My goal is to have my already working php form to submit only when the captcha has been completed. Any help would be appreciated.</p>
  
  <pre><code>&lt;?php
  if (isset($_POST['ContactButton'])) {
      $url = 'https://www.google.com/recaptcha/api/siteverify';
      $privatekey = "6LePayETAAAAANJze7opnV6bQEX-n02p4UdZ8xfF";
      $response = file_get_contents($url . "? 
          secret=" . $privatekey . "&amp;response" . $_POST['g-recaptcha- 
          response'] . "&amp;remoteip=" . $_SERVER['REMOTE_ADDR']);
      $data = json_decode($respose);
      if (isset($data -&gt; success) AND $data -&gt; success == true) {
          $name = $_POST['name'];
          $email = $_POST['email'];
          $phone = $_POST['phone'];
          $message = $_POST['message'];
          $formcontent = " From: $name \n Phone: $phone \n Message: $message";
          $recipient = "magicmacaroni@gmail.com";
          $subject = "Contact Form";
          $mailheader = "From: $email \r\n";
          mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
          header('Location: contact-thank-you.html');
          exit();
      } else {
          header('location: index.html?captchafail=True');
      }
  }
  ?&gt;
  </code></pre>