php產生驗證碼檔案是一項學php的朋友都應該知道的技術哦,這個不既可以讓你的網站安全提高一些,也可以注止一些機器註冊之類的問題哦,下面我們就來看一個簡單的產生驗證碼程式
php產生驗證碼檔案是一項學php的朋友都應該知道的技術哦,這個不既可以讓你的網站安全提高一些,也可以注止一些機器註冊之類的問題哦,下面我們就來看一個簡單的產生驗證碼程式
/ eckNum.php
session_start();
function random(){
$srcstr="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
mt_srand();
$strs="";
for($i=0;$i<6;$i++){
$strs.=$srcstr[mt_rand(0,35)];
}
return strtoupper($strs);
}
$str=random(4); //隨就去幹機產生的字串
$width = 50; //驗證碼圖片的寬度
$height = 25; //驗證碼圖片的高度
@header("Content-Type:image/png");
$_SESSION["code"] = $str;
//echo $str;
$im=imagecreate($width,$height);
//背景色
$back=imagecolorallocate($im,0xFF,0xFF,0xFF);
//模糊97xxoo點顏色
$pix=imagecolorallocate($im,187,230,247);
//字型色
$font=imagecolorallocate($im,41,163,238);
//繪模糊作用的點
mt_srand();
for($i=0;$i<1000;$i++)
{
imagesetpixel($im,mt_rand(0,$width),mt_rand(0,$height),$pix);
}
imagestring($im, 5, 7, 5,$str, $font);
imagerectangle($im,0,0,$width-1,$height-1,$font);
imagepng($im);
imagedestroy($im);
$_SESSION["code"] = $str;
?>
http://www.bkjia.com/PHPjc/630486.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/630486.htmlTechArticlephp產生驗證碼檔案是一項學php的朋友都應該知道的技術哦,這個不既可以讓你的網站安全提高一些,也可以注止一些機器註冊之類的問題哦,下...