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?
The perfect solution is do not create your own g-recaptcha-response input because google will fill it with the response and still yet go ahead creating another g-recaptcha-response textarea but then will not fill it with the response value
It seems that Google wants your opening and closing tags to be outside of other DOM elements such as
<table>
or<div>
. I had the exact same issue which is now resolved. Move your......code to outside of any or tag and it will work. Seems as if Google cannot find the form and inject its form value otherwise.
Today I had this same issue (
g-recaptcha-response
had no value upon submit) on a website of a colleague. Turns out that the tag<form
was mistakenly nested right after the opening tag<table
(not inside a td, but directly after<table
).This was causing the issue.
After moving the tag
form
in way it wrapped thetable
, the value ofg-recaptcha-response
was correctly posted to server side after submit.Yes, the error is the DOM
Code error
Code OK