<?php
session_start();
$ch = array("a","b","c","D","e","F","G","h","i","J","k","L","m","n","O","4","1","Z", "B", "9", "2");//цифры и буквы капчи капчи
$cap = '';
for($i=0; $i < 6; $i++){
$cap .= $ch[rand(0, 20)];
$_SESSION['cap'] = $cap;
}
$img = imagecreate('60', '30');
$back = imagecolorallocate($img, rand(100, 255), rand(100, 255), rand(100, 255));
$black = imagecolorallocate($img, rand(0, 255), rand(0, 255), rand(0, 255));
imagestring($img, rand(3, 9), rand(0, 6), rand(0, 6), $cap, $black);
header('Content-type: image/png');
imagepng($img);
imagedestroy($img);
?>