2

I've installed the ReCaptcha, configured my public and private key, and everything is fine until I type any answer on it, no matter if it's good or wrong, it doesn't even respond with the error there was occurred.

Here is my code:

require_once('recaptchalib.php'); $resp = recaptcha_check_answer ($config->privkey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { echo $resp->error; } 

2 Answers 2

5

I've found the answer after days of searching...

Here is the solution if someone is having a similar problem:

In your rechaptchalib.php change:

define("RECAPTCHA_API_SERVER", "http://api.recaptcha.net"); define("RECAPTCHA_API_SECURE_SERVER", "https://api-secure.recaptcha.net"); define("RECAPTCHA_VERIFY_SERVER", gethostbyname('api-verify.recaptcha.net')); 

To the:

define("RECAPTCHA_API_SERVER", "http://www.google.com/recaptcha/api"); define("RECAPTCHA_API_SECURE_SERVER", "https://www.google.com/recaptcha/api"); define("RECAPTCHA_VERIFY_SERVER", "www.google.com"); 

It was probably caused by the outdated PHP library, so it'll be better for you to download the latest library also:

http://code.google.com/p/recaptcha/downloads/list?q=label:phplib-Latest

Thanks everyone.

Sign up to request clarification or add additional context in comments.

2 Comments

Yes. version 1.11 (for sure) has the new URLs.
Note that verification recaptcha_check_answer(...) is always done over http and never over https. So your private key is sent in clear text, even if your public key is sent encrypted. Odd choice on their part.
0

You need to have public key in your form file & private key in config file:

<html> <body> <!-- the body tag is required or the CAPTCHA may not show on some browsers --> <!-- your HTML content --> <form method="post" action="verify.php"> <?php require_once('recaptchalib.php'); $publickey = "your_public_key"; // you got this from the signup page echo recaptcha_get_html($publickey); ?> <input type="submit" /> </form> <!-- more of your HTML content --> </body> </html> 

This is your file where form request goes:

<?php require_once('recaptchalib.php'); $privatekey = "your_private_key"; $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 ("The reCAPTCHA wasn't entered correctly. Go back and try it again." . "(reCAPTCHA said: " . $resp->error . ")"); } else { // Your code here to handle a successful verification } ?> 

For further assistance you can go to: http://code.google.com/apis/recaptcha/docs/php.html

1 Comment

Thats no matter if I have my public key in a config or form file... Your answer doesn't help , unfortunately.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.