How to add captcha to your website ?

Jul

29

2012

I would like to add a captcha security box for my site. How can I do it?

Tags: , , , , , ,

In: Programming Asked By: abisbr [2 Grey Star Level]

 
+1
0
vote
Answer #1

Adding a captcha box to your site is extremely easy! Here’s the how-to.

There are some options on choosing captcha implementations out there, I tried the reCaptcha.So here it is:

1st Step: get your personalized key
First of all, visit the recaptcha.net site and sign up specifying your sites for access. Here you can assign keys for your websites.It’s 100% free!

2nd Step: add the code
In this article I’ll present a php example. reCaptcha comes also for.net,classic asp,java/jsp,perl etc.

The implementation has 2 parts – these lines to the posting form:


require_once('recaptchalib.php');

$publickey = "your_public_key"; // you got this from the signup page

echo recaptcha_get_html($publickey);

These lines make a beautiful customizable(css) insert containing the actual captcha box.

Secondly – to finish the verification, on the server side – the script which is supposed to take over what your form posted and verify if the entered captcha code is valid, add these lines:


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) {

// not a valid captcha code entered, display error

} else {

// valid captcha code entered, go on with the post

}

Who should use this?
Well my first thought is to the web sites which offer the possibility for an unregistered user to insert comments, upload files, in general to ad content.
Why?
Because there can be someone who could spam your web site and the next day when you check it up you see it full of garbage or maybe even worse – down due to maximum disk space quota. Moreover you could have “the luck” your site is crawled by some very important bosts i.e. Google, Bing etc when it contains all that garbage – if you don’t manually validate the user input and suddenly your page rank could drop due to garbage content.
How does it work?
The code you have to enter is displayed as an image. Moreover, the writing in the image contains different character fonts, displayed in general in different axis rotation and having different color. some of the implementations use additional layers over the text like different ink splatter layers, strike throughs, symbols. These are there in order to confuse automatic detectors (like OCR ones for example) when trying to guess the actual text and automatically add it in the verification box. No automation means less chances of spamming.

For the most recent news, distributions, and all supported programming languages please visit the Google Developers page for reCaptcha at:

https://developers.google.com/recaptcha/docs/php

Answers Answered By: aiboogie [228 Blue Star Level]

Answer this Question

Enter name & email to post an Answer. You can also Login / Join us

For a better management of this site please consider Logging in / Joining us before posting a Question. It makes everithing easier for us.

Please enter the captcha code bellow.
Logged in users don't have to use captchas. Don't have an account? Join us!

Link Exchange:

You can add url to the best of the internet directory. Our url is added under Reference Directory
HE Blog Directory WEB LOG SHOWWEB LOG SHOW