Verifying the User's Answer Without Plugins reCAPTCHA

3.3k Views Asked by At

so i am trying to get recaptcha work with my form. This is the code i have for the form.

<form action="" method="post">
 <input type="text" name="text4" id="text4" style="width:400px" /><br/><br/>' . '<script type="text/javascript"
   src="http://www.google.com/recaptcha/api/challenge?k=XXXXXXXXXXXXXXXXXX">
</script>
<noscript>
   <iframe src="http://www.google.com/recaptcha/api/noscript?k=XXXXXXXXXXXXXXXXXX"
       height="300" width="500" frameborder="0"></iframe><br>
   <textarea name="recaptcha_challenge_field" rows="3" cols="40">
   </textarea>
   <input type="hidden" name="recaptcha_response_field"
       value="manual_challenge">
</noscript><input type="button" value="Submit"/>

I'm trying to use the recaptcha without plugins. It was easy to make it show but I'm having a really hard time verify the input. Anyone know how to the the verify without plugin part? Greatly appreciate it.

1

There are 1 best solutions below

0
On BEST ANSWER

Your server side code, to get reCaptcha to work, should be something similar to what's posted here:

There's no way to get reCaptcha to work, without using a solution similar to this, in any server-side language. Here is the code:

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
}