title: Show ReCaptcha Error message in a Div
body: <p>I have been trying to figure out how to show a error message (Please try captcha again)  in a div with php.</p>
  
  <p>Here is the HTML page:</p>
  
  <pre><code>&lt;link href="css/bootstrap.min.css" rel="stylesheet"&gt;
  &lt;link href="css/bootstrapValidator.min.css" rel="stylesheet"&gt;
  &lt;link rel="stylesheet" href="css/style.css"&gt;
  
  
  &lt;script src='https://www.google.com/recaptcha/api.js'&gt;&lt;/script&gt; 
  
  
  
  
  
  &lt;div class="container"&gt;
  
  &lt;form class="well form-horizontal" action="contact.php" method="post"  id="contact_form"&gt;
  &lt;fieldset&gt;
  
  &lt;!-- Form Name --&gt;
  &lt;legend&gt;Contact Us Today!&lt;/legend&gt;
  
      &lt;!-- To Whom Select --&gt;
  
        &lt;div class="form-group"&gt;
          &lt;label class="col-md-4 control-label"&gt;Send To*&lt;/label&gt;
          &lt;div class="col-md-4 selectContainer"&gt;
            &lt;div class="input-group"&gt; &lt;span class="input-group-addon"&gt;&lt;i class="glyphicon glyphicon-list"&gt;&lt;/i&gt;&lt;/span&gt;
              &lt;select id="sendTo" name="sendTo" class="form-control selectpicker" &gt;
               &lt;option value=" "&gt;Select Who To Email&lt;/option&gt;
               &lt;option id="sb" value="sb"&gt;Stephanie&lt;/option&gt;
               &lt;option id="mb" value="mb"&gt;Michael&lt;/option&gt;
               &lt;option id="questions" value="questions"&gt;Questions&lt;/option&gt; 
              &lt;/select&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
  
      &lt;!-- Text input--&gt;
  
      &lt;div class="form-group"&gt;
        &lt;label class="col-md-4 control-label"&gt;First Name&lt;/label&gt;  
        &lt;div class="col-md-4 inputGroupContainer"&gt;
        &lt;div class="input-group"&gt;
        &lt;span class="input-group-addon"&gt;&lt;i class="glyphicon glyphicon-user"&gt;&lt;/i&gt;&lt;/span&gt;
        &lt;input  name="fullname" placeholder="Full Name" class="form-control"  type="text"&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;!-- Text input--&gt;
             &lt;div class="form-group"&gt;
        &lt;label class="col-md-4 control-label"&gt;E-Mail&lt;/label&gt;  
          &lt;div class="col-md-4 inputGroupContainer"&gt;
          &lt;div class="input-group"&gt;
              &lt;span class="input-group-addon"&gt;&lt;i class="glyphicon glyphicon-envelope"&gt;&lt;/i&gt;&lt;/span&gt;
        &lt;input name="email" placeholder="E-Mail Address" class="form-control"  type="text"&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;!-- Text area --&gt;
  
      &lt;div class="form-group"&gt;
        &lt;label class="col-md-4 control-label"&gt;Project Description&lt;/label&gt;
          &lt;div class="col-md-4 inputGroupContainer"&gt;
          &lt;div class="input-group"&gt;
              &lt;span class="input-group-addon"&gt;&lt;i class="glyphicon glyphicon-pencil"&gt;&lt;/i&gt;&lt;/span&gt;
                  &lt;textarea class="form-control" name="comment" placeholder="Project Description"&gt;&lt;/textarea&gt;
        &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
  
     &lt;!-- Captcha --&gt;
  
     &lt;div class="form-group"&gt;
        &lt;label class="col-md-4 control-label"&gt;Captcha&lt;/label&gt;
        &lt;div class="col-md-4 inputGroupContainer"&gt;
         &lt;div class="g-recaptcha" data-sitekey="SITE KEY #"&gt;&lt;/div&gt;
       &lt;/div&gt;
    &lt;/div&gt;
  
     &lt;!-- Error message --&gt;
     &lt;div class="errorMessage"&gt;&lt;?php echo $err_message; ?&gt; &lt;/div&gt;
  
     &lt;!-- Button --&gt;
     &lt;div class="form-group"&gt;
       &lt;label class="col-md-4 control-label"&gt;&lt;/label&gt;
       &lt;div class="col-md-4"&gt;
         &lt;button type="submit" class="btn btn-warning" &gt;Send &lt;span class="glyphicon glyphicon-send"&gt;&lt;/span&gt;&lt;/button&gt;
       &lt;/div&gt;
     &lt;/div&gt;
  
    &lt;/fieldset&gt;
    &lt;/form&gt;
  
   &lt;/div&gt;&lt;!-- /.container --&gt;
  
  
  &lt;script src="js/jquery-3.1.1.min.js"&gt;&lt;/script&gt;
  &lt;script src="js/bootstrap.min.js"&gt;&lt;/script&gt;
  &lt;script src="js/bootstrapvalidator.min.js"&gt;&lt;/script&gt;
  &lt;script src="js/index.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>Now here is the php page with code to verify captcha is either false or true. I have tested this and it does work if captcha isn't entered it redirects to a page showing the message and if is verity (true) will send email.</p>
  
  <p>This is the part that verity the captcha response false or true:
    PHP Page:</p>
  
  <pre><code>&lt;?php
  session_start();
  /**
  * This example shows settings to use when sending via Google's Gmail servers.
  */
  
  //SMTP needs accurate times, and the PHP time zone MUST be set
  //This should be done in your php.ini, but this is how to do it if you don't have access to that
  date_default_timezone_set('Etc/UTC');   
  
  //Contact Form Data
  $fullnameField = $_POST['fullname'];
  $emailField = $_POST['email'];
  $commentsField = $_POST['comment'];
  
  $secret="SECRET KEY #";
  $response=$_POST["g-recaptcha-response"];
  $verify=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret={$secret}&amp;response={$response}");
  $captcha_success=json_decode($verify);
  
  if ($captcha_success-&gt;success==false) {
   echo "&lt;p&gt;You are a bot! Go away!&lt;/p&gt;";
   }
   else if ($captcha_success-&gt;success==true) {
         (code to send mail using phpMailer)
   }
  </code></pre>
  
  <p>Everything works right when I fill out form and recaptcha and click send , email is sent. Now when I don't click on recaptcha box and hit send it close's page but shows a page with the text You are a bot! Go away! I know that is what ECHO does, except I don't want that, I would like to be able to put the error message in the errorMessage div on the HTML page.
  I have tried $err_message = 'Recaptcha Failed. Please try again'
  and echo $err_message = 'Recaptcha Failed. Please try again' except neither one of these works either. I am also using a js file to validate the 3 fields, name, email and comment. Any help on this would be great. Have searched all over the internet and haven't come across a solution yet.</p>