Boa noite, fiz este código:
if(isset($_POST["user"]) && isset($_POST["senha"]) && isset($_POST['g-recaptcha-response'])) {
$res = $_POST["g-recaptcha-response"];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://www.google.com/recaptcha/api/siteverify",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "secret=...&response=$res",
));
$response = curl_exec($curl);
$response = json_decode($response);
if(isset($response->success) && $response->success) {
header("Location: dash.php");
}
}else {
die('<script>alert("Captcha error!"); window.location = "index.php";</script>;');
}
}
Mas sempre está retornando false, já tentei sem o json_decode também e mesmo assim nada! A secret e a public key conferem!