How to Make CAPTCHA
CAPTCHA comes from words : Completely Automated Public Turing-test to tell Computers And Humans apart. As the meaning of that sentence, it is being used over hundreds pages to avoid automated requests from any scripts, (especially on registration forms).
Captcha codes were restored in current page’s session and uses PHP scripts to produce image containing the code. The visitor’s computer would not be able to read it. The one who able to read is human, in this case, is the visitor itself.
You need PHP to generate captcha code and store it in current session. Here is the example of the single one :
<?php
session_start();
$str = substr(md5(microtime()),0,8);
$_SESSION["captcha"] = $str;
$img = imagecreate(100,30);
$color = imagecolorallocate($img,59,89,153);
imagestring($img,10,10,10,$str,$color);
imagejpeg($img);
?>
Definition
- Session_start will ask server to start the session for your computer
- MD5 Microtime will generate randomized alpha numerical letter.
- Substr will cut your current randomized letter to 8 digits (i.e.)
- $_SESSION will store the letter in session with name “captcha” (i.e.)
- ImageCreate will surely create solid image with width 100px and height 30px.
- ImageColorAllocate colorize your generated image
- ImageString will write the letter to your generated image
- ImageJPEG will render the image and text within it as true image, the browser also treat this PHP file as JPEG image.
Save the current PHP document to (i.e.) captcha.php
Insert CAPTCHA to Page
The next task is pretty easy. You just have to load captcha.php using img tag. Here is the simple HTML Code :
<html>
<body>
<img src="http://yoursite.com/captcha.php" />
</body>
</html>






jul
this is inspiring
Arie Putranto
That will produce the image obviously,also it is dynamic.
dimassimo
simple way to make a CAPTCHA
thanks julian
top article submission sites
So CAPCTHA is so easy, isn’t it?