reCAPTCHA

Discussions of secure PHP coding. Security in software is important, so don't be afraid to ask. And when answering: be anal. Nitpick. No security vulnerability is too small.

Moderator: General Moderators

Post Reply
TETYYS
Forum Newbie
Posts: 1
Joined: Fri Aug 26, 2011 10:17 am

reCAPTCHA

Post by TETYYS »

I got downloaded reCAPTCHA class, etc., but it's not working always grants access even i leave blank. There's my code :

Code: Select all

$cookie_expi = Time() + 3600;
if ($_POST["recaptcha_response_field"]) 
{
require_once('captcha/recaptchalib.php');
$publickey = "6Lf4escSAAAAAN9OLgHanRuVMG8xJQUaQ3Cdd6Dt";
$privatekey = "***NOPE***"; 
$resp = recaptcha_check_answer ($privatekey,
                                $_SERVER["REMOTE_ADDR"],
                                $_POST["recaptcha_challenge_field"],
                                $_POST["recaptcha_response_field"]);
  if (!$resp->is_valid) {
    // What happens when the CAPTCHA was entered incorrectly
         die("<title>Tetgud loto - Neteisingas kodas</title><br /><h3><center>Neteisingas kodas</center><br /><center><a href='zltglvform.php'>Bandyti dar karta</a></center></h3>");
  } else {
      setcookie("tetgudlotocaptchacount",0,$cookie_expi);
    // Your code here to handle a successful verification
  }

}
User avatar
Mordred
DevNet Resident
Posts: 1579
Joined: Sun Sep 03, 2006 5:19 am
Location: Sofia, Bulgaria

Re: reCAPTCHA

Post by Mordred »

Your "if ($_POST["recaptcha_response_field"])" cuts the check and the die(). Reorder.
Post Reply