reCaptcha system using Google API and PHP


In most of the website there is a reCaptcha system form the form. The reCaptcha system will support you to change the captcha code b without refreshing the form. It will also enable the audio captcha also. SO in this article I will explain how to create a reCaptcha using PHP and Google API.

reCaptcha system using Goole API and PHP

You can view demo and download the sample file below

Download FileDemo

What you have to do is first you have to get your Public and Private Key of Google reCaptcha API. You can register the API below,

http://www.google.com/recaptcha/whyrecaptcha

Sign up with your Google account.

How to get Google API key?

Now you will get both Public and Private Key. Replace the $publickey and $privatekey in index.php

//Include reCaptcha liberary
require_once('recaptchalib.php');
/* Related Tutorials- 
http://www.webinfopedia.com/Web-Development
*/
// Get a key from https://www.google.com/recaptcha/admin/create
$publickey = "Your-Public-Key";
$privatekey = "Your-Private-Key";

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

reCaptchaYou can also add the other html form element in the reCaptcha form. This reCaptcha system works using Google API. By using reCaptcha system you can make an user-friendly captcha for your web forms.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>