Getting Null in g-recaptcha-response Google's reCaptcha
<p>I am trying to implement Google's reCaptcha v.2.0 but i am getting null in <strong>g-recaptcha-response</strong> due to this reCaptcha is not working properly and I am always getting the error that <strong>Please click on the reCAPTCHA box.</strong> even if I successfully submitted the Captcha. I <code>var_dump</code> the <code>$_POST['g-recaptcha-response']</code> and I am getting <code>null</code>. Please help me. Below is my code.</p>

<p><strong>HTML</strong></p>

<pre><code>&lt;head&gt;
    &lt;script src="https://www.google.com/recaptcha/api.js"&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;form action="" method="POST"&gt;
    &lt;div class="g-recaptcha" style="margin-left: 230px; margin-top: 40px;" data-sitekey="MySiteKey"&gt;&lt;/div&gt;
&lt;/form&gt;
</code></pre>

<p><strong>PHP</strong></p>

<pre><code>if (isset($_POST['submit'])) {
    if (isset($_POST['g-recaptcha-response']) &amp;&amp; !empty($_POST['g-recaptcha-response'])) {
        //your site secret key
        $secret = 'My Site Secret Key';
        //get verify response data
        $verifyResponse = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret=' . $secret . '&amp;response=' . $_POST['g-recaptcha-response']);
        $responseData = json_decode($verifyResponse);

        if ($responseData-&gt;success) {
            // My All Logic Here
        } else {
            $error[] = 'Robot verification failed, please try again.';
        }
    } else {
        $error[] = 'Please click on the reCAPTCHA box.';
    }
}
</code></pre>

<p>I am always getting the error <strong>Please click on the reCAPTCHA box.</strong> on successful submission too. Please help me. Thanks in advance.</p>

<p><strong>Note:-</strong> There is no <strong>table</strong> tag used in between the Form. </p>