'g-recaptcha-response' Problem when trying to verify user's response for reCaptcha

302 views
Skip to first unread message

Don G

unread,
Jan 15, 2015, 12:01:24 PM1/15/15
to reca...@googlegroups.com
I am having a problem setting up the code to verify the user's response after checking the recaptcha box.

I am using this example code:
   https://github.com/google/ReCAPTCHA/blob/master/php/example-captcha.php

By itself, $_POST['g-recaptcha-response'] returns a long string of letters and numbers.  So far so good.

But when I use the following code from the example:

196    // Was there a reCAPTCHA response?
197    if ($_POST["g-recaptcha-response"]) {
198         $resp = $reCaptcha->verifyResponse(
199         $_SERVER["REMOTE_ADDR"],
200         $_POST["g-recaptcha-response"]
201         );
202   }

I get the following errors:
    Notice: Undefined variable: reCaptcha in [program name] on line 198
   
Fatal error: Call to a member function verifyResponse() on a non-object in [program name] on line 198

Please tell me how to fix this.
Reply all
Reply to author
Forward
0 new messages