<?PHP
session_start();$_SESSION['authnum']=mt_rand(1000,9999); //获取一个四位随即数//生成验证码图片
Header("Content-type: image/PNG"); $im = imagecreate(62,20);
$black = ImageColorAllocate($im, 0,0,0);
$white = ImageColorAllocate($im, 255,255,255);
$gray = ImageColorAllocate($im, 200,200,200);
imagefill($im,68,30,$gray); //将四位随机验证码绘入图片
$authnum=$_SESSION['authnum'];
imagestring($im, 5, 14, 2,$authnum, $white);for($i=0;$i<200;$i++) //加入干扰象素
{
$randcolor = ImageColorallocate($im,mt_rand(0,255),mt_rand(0,255),mt_rand(0,255));
imagesetpixel($im, mt_rand()%70 , mt_rand()%30 , $randcolor); //在image图像中用$randcolor颜色在 x,y 坐标上画一个点
}
ImagePNG($im);
ImageDestroy($im);
?>
session_start();$_SESSION['authnum']=mt_rand(1000,9999); //获取一个四位随即数//生成验证码图片
Header("Content-type: image/PNG"); $im = imagecreate(62,20);
$black = ImageColorAllocate($im, 0,0,0);
$white = ImageColorAllocate($im, 255,255,255);
$gray = ImageColorAllocate($im, 200,200,200);
imagefill($im,68,30,$gray); //将四位随机验证码绘入图片
$authnum=$_SESSION['authnum'];
imagestring($im, 5, 14, 2,$authnum, $white);for($i=0;$i<200;$i++) //加入干扰象素
{
$randcolor = ImageColorallocate($im,mt_rand(0,255),mt_rand(0,255),mt_rand(0,255));
imagesetpixel($im, mt_rand()%70 , mt_rand()%30 , $randcolor); //在image图像中用$randcolor颜色在 x,y 坐标上画一个点
}
ImagePNG($im);
ImageDestroy($im);
?>
解决方案 »
- dreamweaver連接mysql數據庫連接不上
- 谁用php+mysql做过工作流啊?请留下联系方式,最好在北京
- OJS开放期刊系统的首页怎么修改
- 请教,小偷表单问题
- php连接oracle问题.
- 请各位推荐一款性价比好 稳定快速的php空间
- 用socket如何编写下列http://211.100.115.37/lxd/liuyue.php?username=try2&password=060621&birth=19530528&length=70的HTTP协议的POST
- 两个问题,非常紧急……在线等待!!
- wamp安装后,在本地输入localhost和本机ip都可以访问,为什么在手机上输入ip就不能访问了
- 钉钉免密登录一直43009
- 关于产生静态页面速度的问题
- 我用phpmyadmin登陆到服务器上的mysql,但是只能看见左边,右边main.php显示不出来?
在你需要的页面用<IMG SRC=pic_check.php>应用,然后在提交页验证用户输入,与SESSION里面保存是否一致即可