1 <?php
2 session_start();
3 create_image();
4 exit();
5
6 function create_image()
7 {
8
9     $md5_hash = md5(rand(
0,999));
10     $security_code = substr($md5_hash,
15, 5);
11     $_SESSION[
"security_code"] = $security_code;
12     $width =
100;
13     $height =
25;
14     $image = ImageCreate($width, $height);
15     $white = ImageColorAllocate($image,
255, 255, 255);
16     $black = ImageColorAllocate($image,
0, 0, 0);
17     ImageFill($image,
0, 0, $black);
18     ImageString($image,
5, 30, 6, $security_code, $white);
19     header(
"Content-Type: image/jpeg");
20     ImageJpeg($image);
21     ImageDestroy($image);
22 }
23 ?>


Tìm kết quả nhanh