<?php
session_start();
//error_reporting(E_ALL);
header("Content-type: image/png");
$_SESSION["captcha"]="";
$gbr = imagecreate(320, 40);
imagecolorallocate($gbr, 96, 125, 139);
$color = imagecolorallocate($gbr, 253, 252, 252);
$font = __DIR__.'/'."font.ttf"; 
//echo $font;exit();
$ukuran_font = 30;
$posisi = 37;
for($i=0;$i<=3;$i++) {
	$kode=substr(md5(mt_rand()),$i,1);
	$_SESSION["captcha"].=$kode;
	$kemiringan= rand(0, 20);
	imagettftext($gbr, $ukuran_font, $kemiringan+($i*rand(1,5)), 8+70*$i+40, $posisi, $color, $font, $kode);	
} 
imagepng($gbr); 
imagedestroy($gbr);