0
我有form與google reCaptcha v2
。但在我的代碼中,當用戶沒有檢查圖標I'm not a robot
時,代碼會將該人員發送到一個新頁面,並顯示消息Please check the the captcha form
。Google ReCAPTCHA設置v2
我需要當人不檢查圖標I'm not a robot
,他/她留在同一頁上的消息:Please check the the captcha form
。這裏是一個example我想
我有一個聯繫表單(姓名,電話和短信)
<?php
$email;$comment;$captcha;
if(isset($_POST['email'])){
$email=$_POST['email'];
}if(isset($_POST['comment'])){
$email=$_POST['comment'];
}if(isset($_POST['g-recaptcha-response'])){
$captcha=$_POST['g-recaptcha-response'];
}
if(!$captcha){
echo '<h2>Please check the the captcha form.</h2>';
exit;
}
$secretKey = "************";
$ip = $_SERVER['REMOTE_ADDR'];
$response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secretKey."&response=".$captcha."&remoteip=".$ip);
$responseKeys = json_decode($response,true);
if(intval($responseKeys["success"]) !== 1) {
echo '<h2>You are spammer ! Get the @$%K out</h2>';
} else {
echo '<h2>Thanks for posting comment.</h2>';
}
你能幫助我嗎?
要小心,你讓你的私鑰。 您必須生成一個新的以避免黑客入侵。 –
謝謝我忘了它 –
@SergiyK。您將需要生成一個新的密鑰,編輯存儲在問題上是可見的SO – DarkBee