title: Install Info For Google reCaptcha on Contact Form PHP File
body: <p>I am trying to install the Google reCaptcha for a Contact page and I have really limited knowledge with php. I'm unsure as to where the information Google requires should go in my php file. Here are Google's instructions for that:</p>
  <blockquote>
  <p>When your users submit the form where you integrated reCAPTCHA, you'll get as part of the payload a string with the name &quot;g-recaptcha-response&quot;. In order to check whether Google has verified that user, send a POST request with these parameters:</p>
  <p>URL: <a href="https://www.google.com/recaptcha/api/siteverify" rel="nofollow noreferrer">https://www.google.com/recaptcha/api/siteverify</a></p>
  <p>secret (required) -    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</p>
  <p>response (required) -  The value of 'g-recaptcha-response'.</p>
  <p>remoteip - The end user's ip address.</p>
  </blockquote>
  <p>And here is my php for the form I use.</p>
  <pre><code>&lt;?php
  $secret = 'SECRET KEY HERE';
  $verificationResponse = $_POST[&quot;g-recaptcha-response&quot;];
  
  $response = file_get_contents(&quot;https://www.google.com/recaptcha/api/siteverify?secret=&quot;.$secret.&quot;&amp;response=&quot;.$verificationResponse);
  $response = json_decode($response, true);
  if($response[&quot;success&quot;] === true){
  // actions if successful
  }else{
  // actions if failed
  }
  
  /* Set e-mail recipient */
  $myemail = &quot;info@thewiseinvestor.net&quot;;
  
  /* Check all form inputs using check_input function */
  $name = check_input($_POST['inputName'], &quot;First and Last&quot;);
  $email = check_input($_POST['inputEmail'], &quot;Required&quot;);
  $phone = check_input($_POST['inputPhone']);
  $message = check_input($_POST['inputMessage'], &quot;Brief Description&quot;);
  
  /* If e-mail is not valid show error message */
  if (!preg_match(&quot;/([\w\-]+\@[\w\-]+\.[\w\-]+)/&quot;, $email))
  {
  show_error(&quot;Invalid e-mail address&quot;);
  }
  /* Let's prepare the message for the e-mail */
  
  $subject = &quot;Contact Message from thewiseinvestor.net&quot;;
  
  $message = &quot;
  
  Someone has sent you a message using your contact form:
  
  Name: $name
  Email: $email
  Phone: $phone
  
  Message:
  $message
  
  &quot;;
  
  /* Send the message using mail() function */
  mail($myemail, $subject, $message);
  
  /* Redirect visitor to the thank you page */
  header('Location:contact.html');
  exit();
  
  /* Functions we used */
  function check_input($data, $problem='')
  {
  $data = trim($data);
  $data = stripslashes($data);
  $data = htmlspecialchars($data);
  if ($problem &amp;&amp; strlen($data) == 0)
  {
  show_error($problem);
  }
  return $data;
  }
  
  function show_error($myError)
  {
  ?&gt;
  &lt;html&gt;
  &lt;body&gt;
  
  &lt;p&gt;Please correct the following error:&lt;/p&gt;
  &lt;strong&gt;&lt;?php echo $myError; ?&gt;&lt;/strong&gt;
  &lt;p&gt;Hit the back button and try again&lt;/p&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  &lt;?php
  exit();
  }
  ?&gt;
  </code></pre>
  <p>HTML Form</p>
  <pre><code>&lt;div class=&quot;row&quot;&gt;
      &lt;div class=&quot;col-md-6 message&quot;&gt;
      &lt;h2&gt;Send Us A Message&lt;/h2&gt;
      &lt;form name=&quot;contactform&quot; method=&quot;post&quot; action=&quot;index.php&quot; class=&quot;form-vertical&quot;&gt;
        &lt;div class=&quot;form-group&quot;&gt;
          &lt;label for=&quot;inputName&quot; class=&quot;control-label&quot;&gt;Name&lt;/label&gt;
            &lt;input type=&quot;text&quot; class=&quot;form-control&quot; id=&quot;inputName&quot; name=&quot;inputName&quot; placeholder=&quot;First and Last&quot;&gt;
        &lt;/div&gt;
        &lt;div class=&quot;form-group&quot;&gt;
          &lt;label for=&quot;inputEmail&quot; class=&quot;control-label&quot;&gt;Email*&lt;/label&gt;
            &lt;input type=&quot;text&quot; class=&quot;form-control&quot; id=&quot;inputEmail&quot; name=&quot;inputEmail&quot; placeholder=&quot;Required&quot;&gt;
        &lt;/div&gt;
        &lt;div class=&quot;form-group&quot;&gt;
          &lt;label for=&quot;inputPhone&quot; class=&quot;control-label&quot;&gt;Phone Number&lt;/label&gt;
            &lt;input type=&quot;text&quot; class=&quot;form-control&quot; id=&quot;inputPhone&quot; name=&quot;inputPhone&quot; placeholder=&quot;Optional&quot;&gt;
        &lt;/div&gt;
        &lt;div class=&quot;form-group&quot;&gt;
          &lt;label for=&quot;inputMessage&quot; class=&quot;control-label&quot;&gt;Message&lt;/label&gt;
            &lt;textarea class=&quot;form-control&quot; rows=&quot;5&quot; id=&quot;inputMessage&quot; name=&quot;inputMessage&quot; placeholder=&quot;Brief Description&quot;&gt;&lt;/textarea&gt;
        &lt;/div&gt;
        &lt;div class=&quot;g-recaptcha&quot; data-sitekey=&quot;DATA SITE KEY HERE&quot;&gt;&lt;/div&gt;
        &lt;div class=&quot;form-group&quot;&gt;
          &lt;button type=&quot;submit&quot; class=&quot;btn btn-custom pull-right hvr-underline-from-left&quot;&gt;Send&lt;/button&gt;
        &lt;/div&gt;
      &lt;/form&gt;
      &lt;/div&gt; &lt;!-- end col-md-6 --&gt; 
  </code></pre>
  <p>I'm really unsure as to where the above information should go. Any assistance is much appreciated.</p>