<?php

/**
 * Simple captcha
 * Author: Donatas Navidonskis
 * 
 */
session_start();

// generate 6 digits number
$numbers = rand(10000, 99999);

// set number to session
$_SESSION["verifycode"] = $numbers;

// set height of image
$Height = 25;
// set width of image
$Width  = 65;

// Creating Background
$Background = imagecreate($Width, $Height);
$Foreground = imagecolorallocate($Background, 255, 255, 255); // white foreground
$TextColor  = imagecolorallocate($Background, 0, 0, 0); // black text color
$FontSize   = 14;

// set header to show image
header("Cache-Control: no-cache, must-revalidate");
header("Content-type: image/jpeg");

// Creating image
imagestring($Background, $FontSize, 5, 5, $numbers, $TextColor);
imagejpeg($Background);

?>