I am working on an inquiry form for a domains for sale and I implemented google reCaptcha to it. The reCaptcha is working fine on my local server using xampp but when I uploaded it on the server, It always response a success=false even if I I checked the capcha. Here is my code:
$url = 'https://www.google.com/recaptcha/api/siteverify';
$privatekey = "KEY";
$response = file_get_contents($url."?secret=".$privatekey."&response=".$_POST['g-recaptcha-response']."&remoteip=".$_SERVER['REMOTE_ADDR']);
$data = json_decode($response);
if(isset($data->success) AND $data->success==true){
//some code
}
else{
//some code
}
I use a separate key for my local development and for the live one. I believe I use the correct secret key and sitekey when i uploaded it to the server. any idea why this is happening?