2015-05-04 236 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