Recaptcha always returns false

I have a problem with my recaptcha. The problem is that it always returns a false value, as it says that the error was not completed. even when the correct word is typed.

Everything was updated using the latest library, and checked the code and the public / private key three times.

The problem, I believe, lies here ....

require_once('recaptchalib.php'); $privatekey = "************************************"; $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { $error_string .= '<center>The reCAPTCHA wasnt entered correctly. Go back and try it again.</center><br />'; } 

I followed this example, so I do not see what is happening. He has been with him for several days!

https://developers.google.com/recaptcha/docs/php

Click Code:

 require_once('recaptchalib.php'); $publickey = "**********************"; // you got this from the signup page echo recaptcha_get_html($publickey); 

performed a var reset in the $ resp variable and got this

 object(ReCaptchaResponse)#2 (2) { ["is_valid"]=> bool(false) ["error"]=> string(21) "incorrect-captcha-sol" } 

also executed the var_dump recaptcha response field and got:

 NULL 

var dump post ...

 array(7) { ["user"]=> string(0) "" ["pass1"]=> string(0) "" ["pass2"]=> string(0) "" ["email"]=> string(0) "" ["email2"]=> string(0) "" ["gender"]=> string(4) "Male" ["register"]=> string(8) "register" } 

dump request var ...

 array(10) { ["user"]=> string(0) "" ["pass1"]=> string(0) "" ["pass2"]=> string(0) "" ["email"]=> string(0) "" ["email2"]=> string(0) "" ["gender"]=> string(4) "Male" ["register"]=> string(8) "register" ["PHPSESSID"]=> string(26) "4e79u2fdgrrufvb79einufcmq6" ["cprelogin"]=> string(2) "no" ["cpsession"]=> string(65) ":fX5Z1aWfbsgjGfgb3b3J7koo3Y58y5ntgM6k8GTdrQ4YAcqaywAKnD7PRiayfXv3" } 
+4
source share
1 answer

Thanks for the support. I decided that the problem is resolved if anyone encounters this problem in the future.

My form was inside my table, for example

 <table><form>...</form></table> 

Apparently the form should be a table first!

+1
source

Source: https://habr.com/ru/post/1448003/


All Articles