reCaptcha always fails, says "incorrect-captcha-sol"

9,226 views
Skip to first unread message

Nina Reuschling

unread,
May 13, 2013, 1:54:12 PM5/13/13
to reca...@googlegroups.com
Hello,

I just implemented the reCaptcha PHP Code on my homepage and ran into some problems.
The contact form loads the reCaptcha box successfully, so far everything ist good.
The specified php file is loaded via "post"-action. And returns the user-defined error-message.

I tried several times, I'm absolute sure, that I entered the correct captures.
I already checked private/public keys, no misunderstandings.

For my eyes everything seems to be correct, but it just won't work.

Any ideas? Or known issues? Thanks a lot!



Here are the code-passages in question:

File: contact.php:
        <form method="post" action="mail.php">
        [...]
              <?php
                  require_once('recaptchalib.php');
                  $publickey = "here-is-my-publickey-no-error-on-that-one";
                  echo recaptcha_get_html($publickey);
                  ?>
<input type="submit" value="send" name="B1" style="float: right">
</form>
>

File: mail.php:
<?php
   require_once('recaptchalib.php');
   $privatekey = "here-is-my-privatekey-already-checked-that";
   $resp = recaptcha_check_answer ($privatekey,
                                $_SERVER["REMOTE_ADDR"],
                                $_POST["recaptcha_challenge_field"],
                                $_POST["recaptcha_response_field"]);

   if (!$resp->is_valid) {
      die ("<br> Please try again!<br>" .
      "(reCAPTCHA says: " . $resp->error . ")<br><br>- <a href='javascript:history.back()'>zurück</a> -");
   } else {
             [...]
             include ("mailsend.php);
   }
?>



Nina Reuschling

unread,
May 14, 2013, 5:04:42 AM5/14/13
to reca...@googlegroups.com
Indeed, I placed the <form>-tags within a few cells. I just changed that and..... got another error:
This time it says: "Could not open socket" - without my custom error message around.

Nina Reuschling

unread,
May 14, 2013, 7:04:12 PM5/14/13
to reca...@googlegroups.com
Hello and thanks again for your support,

#1 - I checked the lines containing the google-server-data, everything is up to date.

#2 It may be a problem with my hoster, as I found some critical notes about allowing such connections.
On the other hand, I just ran phpinfo() and found 'Sockets enabled' - so... there should be no problem(?)

#3 I re-checked the file, which is triggered from my <form>. In fact require_once('recaptchalib.php'); is the second line of the document, right after <?

Unfortunatly I'm not really experienced with php, I'm merely able to code some simple stuff, unterstand and use code-sniplets.

Nina Reuschling

unread,
May 15, 2013, 8:35:50 AM5/15/13
to reca...@googlegroups.com
okay, I tried that.
Now it says:

"Warning: fsockopen() [function.fsockopen]: unable to connect to www.google.com:80 (Connection timed out) in /[...]/html/recaptchalib.php on line 80
Could not open socket"

And yes, there is a noticable delay, between sending the form and getting the error message.




On Wednesday, May 15, 2013 11:08:29 AM UTC+2, Dom wrote:
Hi,

Can you try to edit the recaptchalib.php file and change the function call '@fsockopen(...'  to 'fsockopen(...' around about line 80 (ie. remove the @ from in front of the function)? That will give you a more informative error message.
--
You received this message because you are subscribed to the Google Groups "reCAPTCHA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to recaptcha+...@googlegroups.com.
To post to this group, send email to reca...@googlegroups.com.
Visit this group at http://groups.google.com/group/recaptcha?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Nina Reuschling

unread,
Jun 1, 2013, 5:15:04 PM6/1/13
to reca...@googlegroups.com
Hello again,
according to the webspace provider that fsocket-connection should be working.
Is there any other thing I could try, before trying another captcha-system?

Thanks!

Keith Norris

unread,
May 13, 2013, 9:55:57 PM5/13/13
to reca...@googlegroups.com
Looks good to me too, so I'll throw out a random thought. Do you use <table></table> to format your form? If so, be sure that the <form> tag is completely outside the table:

   <form> ... <table> ... </table> ... </form>

I know having the <form> inside the <table> has caused mysterious-looking problems for others in the past....

Good luck!

Keith Norris

unread,
May 14, 2013, 5:30:35 PM5/14/13
to reca...@googlegroups.com
Bummer. OK, let's assume this is still progress (I know, not much of an assumption)....

I did a quick search within the forum and found a lot of posts with that error message, but one in particular stands out. Look inside recaptchalib.php and verify the latest and greatest path names in the first section:

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");

Keith Norris

unread,
May 14, 2013, 5:35:16 PM5/14/13
to reca...@googlegroups.com
Ack, I posted that last message before I was ready. If the addresses look correct, there were two other ideas that had a lot of merit:
  1. Can you confirm your hosting service allows/supports outbound socket connections? If not, that is why the socket won't open. Depending on your expertise level, I saw one reference from a person who replaced the recaptchalib socket calls with cURL calls....
  2. Is your include/require for recaptchalib.php tucked away inside a PHP function? If so, it may create a local scope for some of the critical variables and "hide" them from your socket calls. The solution is to move the include/require for recaptchalib.php up to the top of your PHP file and be sure it is not inside any functions.

Hopefully, one of those items will do the trick. Good luck.


Dom Sekotill

unread,
May 15, 2013, 5:08:29 AM5/15/13
to reca...@googlegroups.com
Hi,

Can you try to edit the recaptchalib.php file and change the function call '@fsockopen(...'  to 'fsockopen(...' around about line 80 (ie. remove the @ from in front of the function)? That will give you a more informative error message.

On 15/05/13 00:04, Nina Reuschling wrote:

Rok Bernardič

unread,
Apr 2, 2018, 9:50:52 AM4/2/18
to reCAPTCHA
in root directory from the script set php.ini with this:

allow_url_fopen = On
Reply all
Reply to author
Forward
0 new messages