代码也是网上找的,自己稍微修改了下,code放在session里面,md5加密了一下,网上很多说这样很容易破解,但是作为一名业余的php程序员实在不知道有什么更好的办法了,希望知道更好办法的同学不吝赐教。
<?php
//error_reporting(E_ALL^E_NOTICE);
session_start();
header("Content-type: image/png");
$str = "2,3,4,5,6,7,8,9,a,b,c,d,f,g,h,i,j,k,m,n,p,q,r,s,t,u,v,w,x,y,z";
$list = explode(",", $str);
$cmax = count($list) - 1;
$verifyCode = '';
for ( $i=0; $i < 5; $i++ ){
$randnum = mt_rand(0, $cmax);
$verifyCode .= $list[$randnum];
}
$_SESSION['ok358_code'] = md5($verifyCode);
$im = imagecreate(92,28);
$black = imagecolorallocate($im, 0,0,200);
$white = imagecolorallocate($im, 255,255,255);
$gray = imagecolorallocate($im, 200,200,200);
$red = imagecolorallocate($im, 255, 0, 0);
imagefill($im,0,0,$gray);
//imagestring($im, 5, 10, 8, $verifyCode, $b