title: Using reCAPTCHA on contact-form.php
body: <p>reCaptcha is sending messages without activating the reCaptcha and last night I received over 300 messages a boot.</p>
  
  <p>Help me please how to add so that only sent when the button is activated reCaptcha. Send sends works well but not activation reCaptcha.</p>
  
  <p>To start contact.html within my template I have put this way:</p>
  
  <pre><code>&lt;!-- Start formulario de contacto --&gt;   
                  &lt;div class="row"&gt;
                      &lt;div class="col-md-9"&gt;
                          &lt;h2&gt;Formulario de contacto&lt;/h2&gt;
                          &lt;form action="php/contact-form.php" id="contact-form"&gt;
  
                              &lt;div class="alert alert-success hidden" id="contact-alert-success"&gt;
                                  &lt;strong&gt;Mensaje enviado correctamente!&lt;/strong&gt;  Muchas gracias, pronto nos pondremos en contacto con usted, normalmente nuestro tiempo de respuesta es inferior a 2 horas.
                              &lt;/div&gt;
                              &lt;div class="alert alert-danger hidden" id="contact-alert-error"&gt;
                                  &lt;strong&gt;Error!&lt;/strong&gt; A sucedido un error si lo desea puede contactarnos directamente en XXXX@tize.XXXX
                              &lt;/div&gt;
  
                              &lt;div class="row"&gt;
                                  &lt;div class="col-md-4"&gt;
                                      &lt;div class="form-group"&gt;
                                          &lt;label&gt;Nombre &lt;span class="required"&gt;*&lt;/span&gt;&lt;/label&gt;
                                          &lt;input type="text"
                                              value=""
                                              data-msg-required="Por favor introduzca su nombre"
                                              class="form-control"
                                              name="name" id="name"&gt;
                                      &lt;/div&gt;
                                  &lt;/div&gt;
                                  &lt;div class="col-md-4"&gt;
                                      &lt;div class="form-group"&gt;
                                          &lt;label&gt;eMail &lt;span class="required"&gt;*&lt;/span&gt;  &lt;/label&gt;
                                          &lt;input type="email" 
                                              value=""
                                              data-msg-required="Por favor introduzca su eMail"
                                              data-msg-email="Por favor introduzca un eMail válido"
                                              class="form-control"
                                              name="email"
                                              id="email"&gt;
                                      &lt;/div&gt;
                                  &lt;/div&gt;
                                  &lt;div class="col-md-4"&gt;
                                      &lt;div class="form-group"&gt;
                                          &lt;label&gt;Asunto &lt;span class="required"&gt;*&lt;/span&gt;&lt;/label&gt;
                                          &lt;input type="text" 
                                              value=""
                                              data-msg-required="Por favor introduzca el asunto"
                                              class="form-control"
                                              name="subject"
                                              id="subject"&gt;
                                      &lt;/div&gt;
                                  &lt;/div&gt;
                              &lt;/div&gt;
                              &lt;div class="row"&gt;
                                  &lt;div class="col-md-12"&gt;
                                      &lt;div class="form-group"&gt;
                                          &lt;label&gt;Mensaje &lt;span class="required"&gt;*&lt;/span&gt;&lt;/label&gt;
                                          &lt;textarea
                                              data-msg-required="Por favor introduzca su mensaje"
                                              rows="10"
                                              class="form-control"
                                              name="message"
                                              id="message"&gt;&lt;/textarea&gt;
                                      &lt;/div&gt;
                                  &lt;/div&gt;
                              &lt;/div&gt;                                    
                    &lt;!-- Start Google Recaptcha --&gt;
                       &lt;div class="g-recaptcha" data-sitekey="6Lc88P4SAAAAANiT-ZXILUo-ET4xQmbivHy7uHc8"&gt;&lt;/div&gt;&lt;br&gt;
                    &lt;!-- End Google Recaptcha --&gt;
                              &lt;div class="row"&gt;
                                  &lt;div class="col-md-12"&gt;
                                      &lt;input type="submit" value="Enviar mensaje" class="btn btn-primary" data-loading-text="Cargando..."&gt;
                                  &lt;/div&gt;
                              &lt;/div&gt;
                          &lt;/form&gt;  
                      &lt;/div&gt;
                     &lt;!-- End formulario de contacto --&gt;
  </code></pre>
  
  <p>And in php form to send the messages have this post with contact-form.php :</p>
  
  <pre><code>   &lt;?php
  session_cache_limiter('nocache');
  header('Expires: ' . gmdate('r', 0));
  
  header('Content-type: application/json');
  
  // Enter your email address
  $to = 'XXXX@tize.XX';
  
  $subject = $_POST['subject'];
  
  if($to) {
      $name = $_POST['name'];
      $email = $_POST['email'];
  
      $fields = array(
          0 =&gt; array(
              'text' =&gt; 'Name',
              'val' =&gt; $_POST['name']
          ),
          1 =&gt; array(
              'text' =&gt; 'Email address',
              'val' =&gt; $_POST['email']
          ),
          2 =&gt; array(
              'text' =&gt; 'Message',
              'val' =&gt; $_POST['message']
          )
      );
  
      $message = "";
  
      foreach($fields as $field) {
          $message .= $field['text'].": " . htmlspecialchars($field['val'], ENT_QUOTES) . "&lt;br&gt;\n";
      }
  
      $headers = '';
      $headers .= 'From: ' . $name . ' &lt;' . $email . '&gt;' . "\r\n";
      $headers .= "Reply-To: " .  $email . "\r\n";
      $headers .= "MIME-Version: 1.0\r\n";
      $headers .= "Content-Type: text/html; charset=UTF-8\r\n";
  
      if (mail($to, $subject, $message, $headers)){
          $arrResult = array ('response'=&gt;'success');
      } else{
          $arrResult = array ('response'=&gt;'error');
      }
  
      echo json_encode($arrResult);
  
  } else {
  
      $arrResult = array ('response'=&gt;'error');
      echo json_encode($arrResult);
  
  }
  ?&gt;
  </code></pre>
  
  <p>Picture of my form, If anyone wants to see my website please let me know and send you the link. Thank you very much. sending without activating the reCaptcha <a href="http://goo.gl/oSLQG9" rel="nofollow">http://goo.gl/oSLQG9</a></p>