how to add Captcha to my custom form in WordPress without plugin?

Is there any way to add captcha into my custom form in WordPress, i have gone through some plugins but it allows only to add Captcha in login, comment forms etc..

i have used Google reCaptcha where i have used this script

Read More
<script type="text/javascript"
       src="http://www.google.com/recaptcha/api/challenge?k=your_public_key">
    </script>
    <noscript>
       <iframe src="http://www.google.com/recaptcha/api/noscript?k=your_public_key"
           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>

it’s working fine on contact page but if i click on submit it’s not validated what code should i place in contact page so, that it works with validation.

Related posts

Leave a Reply

1 comment

  1. You need to be checking for validation of the answer and not just displaying the block with the captcha challenge.
    https://web.archive.org/web/20121108134349/https://developers.google.com/recaptcha/docs/php

      <?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
    }
    ?>