Simple Captchas with PHP and GD
By now, we’ve all encountered captcha images in online forms. Captchas are a necessary evil, and this article will teach you how they’re made.
Please note that while there are better, automatic third party solutions for captchas out there such as ReCaptcha, this tutorial aims merely to explain and demonstrate how such technology actually works. We won’t be explaining what captchas actually are, as it’s assumed to be common knowledge and already covered in greater detail elsewhere.
You must have the GD(Graphics Draw) library installed before proceeding. This library enables drawing of graphics and images through built-in PHP functions. To install it, run
sudo apt-get install php5-gdor if on non-Ubuntu-based operating systems, follow instructions.
Captchas are usually made up of 3 things – shape, distortion, and the text.
We’ll follow the steps mentioned below:
- Display an empty image on the browser.
- Create a shape.
- Generate random lines.
- Generate random dots.
- Generate random text.
The procedural style used in this article is present only because this is a proof of concept, and to keep the final file as simple as possible. In a real project, you would go OOP.
PHP and Neo4j: Introduction to Graph Databases
For a long time, data has been typically stored in tabular form so as to increase the indexing and readability. Nowadays, the trends are changing as Graph databases are quickly gaining popularity. In fact, it would not be wrong to call them "the future of DBMS". New to the world of graphs and databases? Don't […]