简体   繁体   中英

ReCaptcha form integrade not working

am trying to create a ReCaptcha for my form.

i have gone through the documentation, but how do I inter-grade the ReCaptcha to the form.. I used the private key but that don't work...

http://www.the-big-bbq.co.uk/invitation.php#prettyPhoto

this is the site

its showing at the moment, but if i dont enter anything the form still submits.

code:

 <?php
require_once('recaptchalib.php');

// Get a key from https://www.google.com/recaptcha/admin/create
$publickey = "i have added the key here";
$privatekey = "i have added the key here";
# the response from reCAPTCHA
$resp = null;
# the error code from reCAPTCHA, if any
$error = null;

# was there a reCAPTCHA response?
if ($_POST["recaptcha_response_field"]) {
$resp = recaptcha_check_answer ($privatekey,
                                $_SERVER["REMOTE_ADDR"],
                                $_POST["recaptcha_challenge_field"],
                                $_POST["recaptcha_response_field"]);

if ($resp->is_valid) {
        echo "You got it!";
} else {
        # set the error code so that we can display it
        $error = $resp->error;
}
}
 echo recaptcha_get_html($publickey, $error);
?>

I had the same problem. So I added the Java Function validateForm() on my page. So now it won't go to the recapcha step, before all the necessary fields have there correct input.

I used this code in my html form page, to show the recaptcha field:

<!-- Google recaptcha -->
    <tr>

    <td colspan="5">
    <script type="text/javascript"
   src="http://www.google.com/recaptcha/api/challenge?k=0000000000000000000000...">
</script>
<noscript>
   <iframe src="http://www.google.com/recaptcha/api/noscript?k=0000000000000000000000..."
       height="65" width="109" frameborder="0"></iframe><br>
   <textarea name="recaptcha_challenge_field" rows="2" cols="2">
   </textarea>
   <input type="hidden" name="recaptcha_response_field"
       value="manual_challenge">
</noscript>
    </td>
    <tr>

I have it to my site. But the server validation: "Verifying the User's Answer Without Plugins". Wont work. I tried adding the verify.php action (and added the necessary .php files to my root.) But nothing.

    <form name="reserveringen" method="post" onsubmit="return validateForm();" action="verify.php">
<?php
require_once('recaptchalib.php');
          $publickey = "0000000000000000000000..."; 
          echo recaptcha_get_html($publickey);
?>

Tips would be great :).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM