<?php
session_start();

/* http://www.montadaphp.net/showthread.php?t=966 */

$text= substr( md5(uniqid (rand())), 0, 5 );
$_SESSION["captchacode"] = $text;
$height = 25;
$width = 70;
$image_p = imagecreate($width, $height);
$black = imagecolorallocate($image_p, 255,255, 255);
$white = imagecolorallocate($image_p, 1, 2, 779);
$font_size = 10;
imagestring($image_p, $font_size, 9, 5, $text, $white);
imagejpeg($image_p, null, 100);
?> 

