Not bad for a first. You can end up making Captcha images with GD too.
(Demo) The site isn't done yet but the captcha works perfectly.
Page containing captcha
PHP Code:
<?
session_cache_limiter("private_no_expire, must-revalidate");
session_start();
$ip = $_SERVER['REMOTE_ADDR'];
$alphabet = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0');
srand(time());
$randstr = "";
for ($i=0; $i<10; $i++){
$random = (rand() % sizeof($alphabet));
$randstr .= $alphabet[$random];
}
$_SESSION["capval" . $ip] = $randstr;
?>
<html>
<head>
<title>Captcha</title>
</head>
<body>
<img src="capimg.php" />
</body>
</html>
capimg.php
PHP Code:
<?
session_cache_limiter("private_no_expire, must-revalidate");
session_start();
$ip = $_SERVER['REMOTE_ADDR'];
$randstr = $_SESSION["capval" . $ip];
header ("Content type: image/jpeg");
$im = @imagecreatetruecolor(100, 25) or die("Cannot Initialize new GD image stream");
$text_color = imagecolorallocate($im, 255, 255, 255);
imagestring($im, 2, 10, 5, $randstr, $text_color);
imagejpeg($im, '', 100);
imagedestroy($im);
?>