宝哥软件园

PHP使用GD库制作验证码(点击验证码或看不到会刷新验证码)

编辑:宝哥软件园 来源:互联网 时间:2021-09-03

这是使用GD库生成验证码的页面

测试。服务器端编程语言(Professional Hypertext Preprocessor的缩写)

?php标题(' Content-type : IMage/JPEG ');$img=imagecreatetruecolor(100,40);$black=imagecolorallocate($img,0x00,0x00,0x 00);$green=imagecolorallocate($img,0x00,0xFF,0x 00);$white=imagecolorallocate($img,0xFF,0xFF,0xFF);imagefill($img,0,0,$ white);//生成随机验证码$ code=for($ I=0;$ I 4;$i ) { $code。=rand(0,9);} imagestring($img,5,10,10,$code,$ black);//为($i=0)添加噪声干扰;$ i50$i ) { imagesetpixel($img,rand(0,100),rand(0,100),$ black);imagesetpixel($img,rand(0,100),rand(0,100),$ green);}//输出验证码头(' content-type : image/png ');image png($ img);image destroy($ img);这是在点击验证码或看不清楚后可以部分刷新的验证码

test2.php

脚本类型='text/javascript '函数shua Xin(){ document . getelementbyid(' code ')。src='test.php?math . random();}/script input type=' text ' br/img id=' code ' src=' http 3360 test . PHP ' onclick=' suhuaxin()'/span onclick=' suhuaxin()'不清楚?/span br/如下图所示:

摘要

以上是PHP使用GD库制作边肖介绍的验证码的方法(点击验证码或看不到会刷新验证码)。希望对大家有帮助。如果你有任何问题,请给我留言,边肖会及时回复你。非常感谢您对我们网站的支持!

更多资讯
游戏推荐
更多+