Archive

Posts Tagged ‘CAPTCHA’

How to Use Free Captchas.net and Stop SPAM

July 16th, 2007 1 comment

Captchas.net is a great free service that provides web accessible CAPTCHA so that your online forms can be saved from SPAM. Captchas.net also provides sample code for ASP, JSP, Perl and Python. The site is available in English, German, and Italian.

Here are some simple steps on how to install it on a PHP-driven web page, such as a contact form, which will be used in the instructions below.

  1. Go to the Captchas.net web site and register an account.
  2. Go to the page with the Captchas PHP code.
  3. At the top of the page, download the PHP file “CaptchasDotNet.php” from the text link given (this file will be included in both PHP pages we create).
  4. From the “query.php” example, create a PHP file for a contact form (or whatever) in your web site files. (The HTML in the given example is poorly coded, so I suggest completely rewriting it, or go to this example contact page that I set up with for an example of a web standards layout, and it uses Captchas too.)
  5. In the PHP code, modify the client and secret variables; you should have received them when registering in Step 1. The other variables are optional, but you will probably need to tweak a bit to fit your design.
  6. From the “check.php” example, create a PHP file to perform the Captcha checking and form processing (don’t forget to ensure the action of your form goes to this page).
  7. In the PHP code, modify the client and secret variables as done in step 5.
  8. You may wish to modify the error messages in the if and elseif statements.
  9. After the else statement, enter the code for emailing the Contact information (or whatever code you want to run if the Captcha check is OK.)