title: Cant get google recaptcha v2 to prevent form submission
body: <p>So I can successfully get the captcha to validate, using the following code. </p>
  
  <pre><code>  &lt;/p&gt;
  &lt;?php
  if(isset($_POST['g-recaptcha-response'])){
  echo verify($_POST['g-recaptcha-response']);
  
  }
  
  function verify($response) {
  $ip = $_SERVER['blank']; //server Ip
  $key="secretkey"; // Secret key
  
  //Build up the url
  $url = 'https://www.google.com/recaptcha/api/siteverify';
  $full_url = $url.'?secret='.$key.'&amp;response='.$response.'&amp;remoteip='.$ip;
  
  //Get the response back decode the json
  $data = json_decode(file_get_contents($full_url));
  //Return true or false, based on users input
  if(isset($data-&gt;success) &amp;&amp; $data-&gt;success == true) {
  return True;
  }
  return False;
  }
  ?&gt;
  &lt;p style="text-align: justify;"&gt;
  </code></pre>
  
  <pre class="lang-html prettyprint-override"><code>&lt;script type="text/javascript"&gt;
   function verify(){
   var serializedValues = jQuery("#infoForm").serialize();
   jQuery.ajax({ type: 'POST',url:"verify.php",data: serializedValues,success:function(result){
   if(result){
   $('#show').html('Your Form Successfully Submitted');
   $('.formwrap').hide(result);
   return true;
   }
   }});
   $('#show').html('Please Enter Valid Captcha');
   return false;
  }
   var onloadCallback = function() {
   grecaptcha.render('captcha_ele', {
   'sitekey' : 'Enter Your Site Key Here', // Site key
   });
   };
   &lt;/script&gt;
  </code></pre>
  
  <p>However, when I click submit, regardless of what the captcha says, form will still submit. My email form process is as follows...</p>
  
  <pre><code>&lt;!-- language: lang-css --&gt;
  
  $("#blank").submit(function() {
      $.post('assets/php/email-process.php', {name: $('#name').val(), email: $('#email').val(), message: $('#message').val(), myFormSubmitted: 'yes'}, 
      function(data) {
          $("#formResponse").html(data).fadeIn('100');
          $('#name, #email, #message').val(''); /* Clear the inputs */
      }, 'text');
      return false;
  }); 
  </code></pre>
  
  <pre class="lang-html prettyprint-override"><code>&lt;?php
  if ($_POST['leaveblank'] != '' or $_POST['dontchange'] != 'http://') {
     // display message that the form submission was rejected
  }
  else {
     // accept form submission
  $to = 'info@blank'; // Replace with your email  
      $subject = 'Message from website visitor'; // Replace with your $subject
      $headers = 'From: ' . $_POST['email'] . "\r\n" . 'Reply-To: ' . $_POST['email'];    
  
      $message = 'Name: ' . $_POST['name'] . "\n" .
                 'E-mail: ' . $_POST['email'] . "\n" .
                 'Subject: ' . $_POST['subject'] . "\n" .
                 'Message: ' . $_POST['message'];
  
      mail($to, $subject, $message, $headers);    
      if( $_POST['copy'] == 'on' )
      {
          mail($_POST['email'], $subject, $message, $headers);
      }
      echo 'Thank you for your Email. We will get in touch with you very soon.';
  
  }
  
  
  ?&gt;
  </code></pre>