A simple PHP Captcha, if you want you can use a JPG format but I think PNG is way clearer. It features 2 lines covering some of the Captcha to prevent bots reading the text. You can also mess around with the colours/size/position.
Example: http://www.x32.bz/images/captcha.php
Example: http://www.x32.bz/images/captcha.php
PHP Code:
<?php
session_start();
$mix = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789"; // Characters to use in the captcha I have taken out 0,O,1,l,I to avoid confusion
$rand = substr(str_shuffle($mix), 0, 5); // Generate a random 5 character string from the $mix
$_SESSION['captcha_image_value'] = md5($rand); // Assign the randomly generated string to a session variable so we may reference it later
$image = imagecreate(60, 30); // Create a 60 x 30 image
$bgColor = imagecolorallocate ($image, 41, 41, 41); // Assign a background color using the RGB values 41, 41 and 41
$textColorV = imagecolorallocate ($image, 175, 175, 175);
$lineColorV = imagecolorallocate ($image, 240, 0, 0);
imageline($image,0,12,60,20,$lineColorV); // Draw a line from (0,12) to (60,20) of color $line color
imageline($image,0,20,60,12,$lineColorV);
imagestring ($image, 5, 5, 8, $rand, $textColorV); // Write the string to the image
// Some headers to prevent the image from being cached, thus ensuring the browser gets a new image every time the page is loaded
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header('Content-type: image/png'); // Makes browser recognize this script as an image
imagepng($image);
imagedestroy($image);
?>