2016-03-25 80 views
0

我有formgoogle reCaptcha v2。但在我的代碼中,當用戶沒有檢查圖標I'm not a robot時,代碼會將該人員發送到一個新頁面,並顯示消息Please check the the captcha formGoogle 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

你能幫我嗎?對我來說它很難。 –