View file captcha.php
<?php session_name("SID"); session_start(); $im = imageCreateFromGIF('img/captcha.gif'); $text = imageColorAllocate($im, 666, 666, 666); $code = mt_rand(1000,9999); $_SESSION['code']=$code; imageString($im, 5, 8, 2, $code, $text); ImageGIF($im); ImageDestroy($im); header("Content-Type: image/GIF"); ?>