<?php
session_start();
$alp='QWERTYUIOPASDFGHJKLZXCVBNM123446789';
$len=strlen($alp);
$code=NULL;
$image = imagecreatetruecolor(72, 30);
$x = NULL;
$chars = mt_rand(4, 6);
for($i=0; $i<$chars; $i++)
{
$x+=rand(7, 11);
$code .= $symb = $alp{mt_rand(0,$len-1)};
imagechar($image, 5, $x, mt_rand(2, 14),$symb, 0x00FFFF);
}
$_SESSION['code'] = $code;
imagefilter($image, IMG_FILTER_EMBOSS);
header('Content-Type: image/png');
Imagepng($image);
ImageDestroy($image);
?>