4
votes

I have a problem with google reCaptcha,

I want captcha to work like this http://www.superlike.net/login.php?user=VALUE

Where user=value will be hidden in login form of google captcha
Example - <input name="user" type="hidden" value="VALUE">

When I try to use like this google is unable to verify captcha and captcha skips to login page without verifying captcha.
I used -

<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>

I am currently using - http://www.9lessons.info/2014/12/google-new-recaptcha-using-php-are-you.html

But when I use this it automatically skips captcha and user logs in.

Any way to do it easily and verify captcha on single page with javascript or something else?

1

1 Answers

1
votes

Hello i solved this question

<?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!';
}

}
?>

This worked for me!