2016-03-25 9 views
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>'; 
    } 

は、あなたがそれで私を助けることができるのですか?

+0

プライベートキーを使用するように注意してください。 ハッキングを避けるために、新しいものを生成する必要があります。 –

+0

ありがとう、私はそれを忘れる –

+0

@SergiyK。あなたは新しいキーを生成する必要があります。編集内容はSO – DarkBee

答えて

0

#Javascriptを使用して、クライアントにcaptchaが最初にチェックされていることを検証する必要があります。次に、私のキャプチャがチェックされている送信フォームを送信します。

+0

それを手伝ってもらえますか?私にとっては難しいことです。 –

関連する問題