<?php
  session_start(); // start a session

  $image = imagecreatefromjpeg("http://www.virtualalien.net/images/eyecaptcha.jpg"); //create blank image (width, height)
  $textcolor = imagecolorallocate($image, 255, 255, 255); //add text/code color with RGB.
  $code = rand(1000, 9999); //create a random number between 1000 and 9999

  $_SESSION['code'] = ($code); //add the random number to session 'code'
  imagestring($image, 5, 14, 5, $code, $textcolor); //create image with all the settings above.
  header ("Content-type: image/png"); // define image type
  imagepng($image); //display image as PNG
?>
