Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google ReCaptcha not posting 'g-recaptcha-response'

Tags:

This question has been asked before: New Google ReCaptcha not posting/receiving 'g-recaptcha-response' - but there was no proper answer.

I have the exact same set up as him, but the code fails here:

if(!$captcha){    exit; } 

so $captcha=$_POST['g-recaptcha-response'] seems to be empty.

new google recaptcha with checkbox server side php = The 2nd answer here also doesn't seem to work.

Does anyone know why this could happen?

like image 524
frosty Avatar asked Jun 06 '15 17:06

frosty


1 Answers

I encountered this issue and found that my form was closing prematurely in the DOM because it was inside a table. ReCaptcha sets up a display:none g-recaptcha-response textarea and later fills in the data when you complete the captcha. It seems to look for children of the form that the div is in and thus couldn't find the g-recaptcha-response it had initially created. I put the form around the table and it worked fine after that.

like image 158
Kiwimancy Avatar answered Oct 29 '22 13:10

Kiwimancy