Google reCAPTCHA - keep getting `incorrect-captcha-sol`
I have solved this, it is one of the most unusual things I have come across, my syntax was previously:
<table>
<form>
<tr><td></td></tr>
</form>
</table>
I changed it to this:
<form>
<table>
<tr><td></td></tr>
</table>
</form>
Because of this switch, suddenly the recaptcha_response_field
and recaptcha_challenge_field
are posting values back to the form.
I cannot think why this because all MY form variables got posted back before the switch.
Thanks all for the pointers.
Google reCAPTCHA: incorrect-captcha-sol error
I solved the issue using the following code
$response=json_decode(file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=SECRET_KEY_HERE&response=".$captcha."&remoteip=".$_SERVER['REMOTE_ADDR']), true);
if($response['success'] == false){
//Captcha incorrect
}
else {
//Success code here
}
instead of
<?php
require_once('recaptchalib.php');
$privatekey = "xxx";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
"(reCAPTCHA said: " . $resp->error . ")");
} else {
/* proper code */
}
?>
Thanks to Locke Donohoe who suggested the answer here.
Google Recaptcha incorrect-captcha-sol
I eventually figured it out I didn't initialize $resp before I used it.
So I've now got
$resp = null;
before the start of the IF statement and the code is now working correctly.
That's what I get for copy/pasting Google's code and not checking it carefully!
Google recaptcha v3 with codeigniter 3 - incorrect-captcha-sol
This is solved. Here is the solution.
Instead of assigning constant keyword to a php variable, i have echo directly the Constant Keyword.
reCAPTCHA keep saying incorrect-captcha-sol
Fixed it by ending a table before the form then starting the table again once inside the form.
Related Topics
How to Determine If an Array Has Any Elements or Not
Where to Use MySQL_Real_Escape_String to Prevent SQL Injection
Http Header for Downloading Microsoft Word and Excel Files
Program Cant Start Because PHP5.Dll Is Missing
Pdo Bind Unknown Number of Parameters
How to Decode a Base64 String (Gif) into Image in PHP/Html
Moving from MySQL to MySQLi or Pdo
How to Make MySQL Return Utf-8
Why Does PHP's Call_User_Func() Function Not Support Passing by Reference
Google Map: Is a Lat/Lng Within a Polygon
Why Do I Receive "This Value Should Be of Type String" When Using a Datetime Constraint on Symfony 5
Url Encoded Forward Slashes Breaking My Codeigniter App
PHP String Concatenation - "$A $B" VS $A . " " . $B - Performance