title: How to verify hCaptcha response and ensure it is filled?
body: <p>I have followed the tutorial <a href="https://medium.com/@hCaptcha/using-hcaptcha-with-php-fc31884aa9ea" rel="nofollow noreferrer">here</a>.</p>
  
  <p>hCaptcha appears on my site, but the form can be submitted without attempting it. How can I make it a required field?</p>
  
  <p>I have tried the following to make it required.</p>
  
  <pre><code>&lt;?php
  $data = array(
              'secret' =&gt; "my-secret (should start with 0x..)",
              'response' =&gt; $_POST['h-captcha-response']
          );
  $verify = curl_init();
  curl_setopt($verify, CURLOPT_URL, "https://hcaptcha.com/siteverify");
  curl_setopt($verify, CURLOPT_POST, true);
  curl_setopt($verify, CURLOPT_POSTFIELDS, http_build_query($data));
  curl_setopt($verify, CURLOPT_RETURNTRANSFER, true);
  $response = curl_exec($verify);
  var_dump($response);
  ?&gt;
  </code></pre>
  
  <p>And also</p>
  
  <pre><code>&lt;?php
  
    if(isset($_POST['h-captcha-response']) &amp;&amp; !empty($_POST['h-captcha-response']))
    {
          $secret = 'your_secret_key';
          $verifyResponse = file_get_contents('https://hcaptcha.com/siteverify?secret='.$secret.'&amp;response='.$_POST['h-captcha-response'].'&amp;remoteip='.$_SERVER['REMOTE_ADDR']);
          $responseData = json_decode($verifyResponse);
          if($responseData-&gt;success)
          {
              $succMsg = 'Your request have submitted successfully.';
          }
          else
          {
              $errMsg = 'Robot verification failed, please try again.';
          }
     }
  ?&gt;
  </code></pre>
  
  <p>But I get a <code>Notice: Undefined Index:</code> error. I tried to hide the error by editing <code>php.ini</code> and also by adding<br>
   <code>&lt;?php error_reporting (E_ALL ^ E_NOTICE); ?&gt;</code> at the top of my file, but it doesn't work.</p>
  
  <p>When I try to make it required, I get an unexpected end to file error-</p>
  
  <pre><code>$("form").submit(function(event) {
  
     var hcaptchaVal = $('[name=h-captcha-response]').value;
     if (hcaptchaVal === "") {
        event.preventDefault();
        alert("Please complete the hCaptcha");
     }
  });
  </code></pre>