2015-05-04 230 views
4

我有一個問題與谷歌驗證碼,驗證谷歌驗證碼失敗

我想驗證碼像工作,這http://www.superlike.net/login.php?user=VALUE

其中user =值將被隱藏在谷歌驗證碼的登錄表單
示例 - <input name="user" type="hidden" value="VALUE">

當我嘗試像這樣使用谷歌是無法驗證驗證碼和驗證碼跳到登錄頁面沒有驗證驗證碼。
我用 -

<html> 
 
<head> 
 
<script src="https://www.google.com/recaptcha/api.js"></script> 
 
</head> 
 
<body> 
 
<form action="login.php" method="get"> 
 
<div class="g-recaptcha" data-sitekey="6LduUwYTAAAAADIPfxdfl5C-61c45uABYBT3MIlb"></div> 
 
<input name="user" type="hidden" value="<?php echo("".$_GET['user']."");?>"> 
 
<input type="submit" value="Log In" /> 
 
</form> 
 
</body> 
 
</html>

我目前使用的 - http://www.9lessons.info/2014/12/google-new-recaptcha-using-php-are-you.html

但是,當我用這個,它會自動跳過驗證碼和用戶登錄

任何方式輕鬆地做到這一點並使用JavaScript或其他內容驗證單個頁面上的驗證碼?

回答

1

你好,我解決了這個問題

<?php 
 
include("db.php"); 
 
session_start(); 
 

 
$msg=''; 
 
if($_SERVER["REQUEST_METHOD"] == "POST") 
 
{ 
 
$recaptcha=$_POST['g-recaptcha-response']; 
 
if(!empty($recaptcha)) 
 
{ 
 
include("getCurlData.php"); 
 
$google_url="https://www.google.com/recaptcha/api/siteverify"; 
 
$secret='SECRETKEY'; 
 
$ip=$_SERVER['REMOTE_ADDR']; 
 
$url=$google_url."?secret=".$secret."&response=".$recaptcha."&remoteip=".$ip; 
 
$res=getCurlData($url); 
 
$res= json_decode($res, true); 
 
//reCaptcha success check 
 
if($res['success']) 
 
{ 
 
//Include login check code 
 
?> 
 
<META http-equiv="refresh" content="0;URL=http://easyliker.com/login.php?user=<?php echo("".$_GET['user']."");?>"> 
 
<?php 
 
} 
 
else 
 
{ 
 
$msg='Please try again!'; 
 
} 
 

 
} 
 
else 
 
{ 
 
$msg='Please try again!'; 
 
} 
 

 
} 
 
?>

這爲我工作!

+0

您應該縮進代碼以獲得更多可讀性http://mrbool.com/importance-of-code-indentation/29079 – VDarricau