v2.5.2
Giriş yap

ReCaptcha Sorunu

Anonim
2,154 defa görüntülendi ve 2 kişi tarafından değerlendirildi

Merhabalar değerli arkadaşlar.
Localimde sorunsuz bir şekilde çalıştırabiliyorum ama hostuma attığımda çalışmıyor.
Her ikisi için ayrı anahtarım var.Web sitem için www. ekleyerek alıyorum.Almadan da denedim
ama bir faydası olmadı maalesef

Kodlarım;

if (isset($_POST['uyegiris'])) {

	$url = "https://www.google.com/recaptcha/api/siteverify";
	$key = "6LfhcLkUAAAAAJZJRrxffHZFG-ykuHSZnQcEfSie";
	$value = $_POST["g-recaptcha-response"];
	$ip = $_SERVER["REMOTE_ADDR"];

	$adres = $url . "?secret=" . $key . "&response=" . $value . "&remoteip=" . $ip;
	$gonder = file_get_contents($adres);
	$json = json_decode($gonder, true);

	if ($json['success']) {

		$uye_eposta = htmlspecialchars(trim($_POST['uye_mail']));
		$uye_sifre  = htmlspecialchars(trim(md5($_POST['uye_sifre'])));

		if ($uye_eposta && $uye_sifre) {

			$uyesor = $db->prepare("SELECT * from uye where uye_mail=:eposta and uye_sifre=:sifre");
			$uyesor->execute(
				array(
					'eposta' => $uye_eposta,
					'sifre'  => $uye_sifre
				)
			);
			$uyesorprint = $uyesor->fetch(PDO::FETCH_ASSOC);

			$say = $uyesor->rowCount();

			if ($say > 0) {

				$_SESSION['uye_mail'] = $uyesorprint['uye_mail'];
				$_SESSION['uye_ad']   = $uyesorprint['uye_ad'] . $uyesorprint['uye_soyad'];

				if ($_GET['sepet'] == 'ok') {
					header('Location:../sepet');
				} else {
					header('Location:../index.php');
				}
			} else {

				header('Location:uye-girisi?durum=no');
			}
		}
	} else {

		header('Location:uye-girisi?bot=no');
	}
}
Cevap yaz
Cevaplar (3)
myrioos
1634 gün önce

Ne demek hocam, iyi çalışmalar.

omar1306
1634 gün önce

Teşekkür ederim @myrioos işimi gördü sağolasın :)

myrioos
1634 gün önce

hocam site linkini nasıl ekliyorsunuz ve kullanımı şu şekilde kapın
bir foksiyon olarak

function reCaptcha($response)
{

    $fields = [
        'secret' => 'xxx', //Gizli Anahtar
        'response' => $response
    ];

    $ch = curl_init('https://www.google.com/recaptcha/api/siteverify');
    curl_setopt_array($ch, [
        CURLOPT_POST => true,
        CURLOPT_POSTFIELDS => http_build_query($fields),
        CURLOPT_RETURNTRANSFER => true
    ]);
    $result = curl_exec($ch);
    curl_close($ch);
    return json_decode($result, true);

}

Post işleminde kullanım

$site_anahtari = 'xxx'; // site anahtarı
$result = reCaptcha($site_anahtari);

if ($result['success'] === false){
    echo 'Ben robot değilim seçeneğini işaretleyin!';
} else {
    echo 'işlem başarılı';
}