|
Location: Web development - PHP License: The Intelliproject Open License (IPOL) How to Create CAPTCHA Protection using PHPPosted by Silviu CarageaDescribe how to create CAPTCHA Protection using PHP. It is used to prevent spam abuse on the websites. |
Skill: IntermediatePosted: 15/10/2008Views: 2016Rating: 5.00 /5Popularity: 0.00 |
| Sign Up to vote for this article |
CAPTCHA is a simple test to determine if a user is a computer or a human. It is used to prevent spam abuse on the websites.
Using a captcha test on a website is a great way to ensure, for instance, that a person and not a spambot is filling out a web form. Also, a captcha can make it difficult for a person to continuously resubmit form information.
In brief the CAPTCHA protection works by generating a random string, writing it to an image, then storing the string inside of a session or by some other method. This is then checked when the form is submitted.
The goal of this tutorial is to demonstrate how to make your own simple CAPTCHA protection using PHP.

The following class load a random background image from all available images specified in $array_images and generate a random string that is draw over this image.
Also the generated string is saved in the user session ($_SESSION['captcha_string']).
Create some background images and save them into "images" subfolder. Save the above class in a file called captcha.php and add at the end of the file the following 2 lines (do not forget to use <?php ?> tags):
Create a file called test_html.php and add the following code:
Also you can download the source code to test this CAPTCHA generator class described in this article.
This article, along with any associated source code and files, is licensed under The Intelliproject Open License (IPOL)
| Silviu Caragea
| Silviu Caragea is the Founder, Administrator and Chief Editor who wrote and runs The IntelliProject. He's been programming since 2000 and now he's student at The Faculty of Economic Cybernetics, Statistics and Informatics from Bucharest. In the same time he's working as software developer at Cratima Software, a Romanian software and web design company that activates both on the local and foreign market, providing its customers with software development services, internet and intranet solutions, web design, graphic design and IT consultancy. His programming experience includes: - C,C++, Visual C++(Win32 API, MFC, ADO, STL, DAO, ODBC, ATL, COM, DirectShow, DirectDraw, WTL) - Open Source libraries :CURL & Boost - HTML, CSS - Java (SE,ME) - JavaScript, Ajax, Google Web Toolkit (GWT) - Php, MySQL -Oracle, PL SQL - C# .NET -Objective C, IPhone SDK, Cocoa Location: |
Sign up to post message on the article message board!