checks.php代码:
<?phpsession_start(); //生成验证码图片 Header("Content-type: image/PNG"); $im = imagecreate(44,18); // 画一张指定宽高的图片 $back = ImageColorAllocate($im, 245,245,245); // 定义背景颜色 imagefill($im,0,0,$back); //把背景颜色填充到刚刚画出来的图片中 $vcodes = ""; srand((double)microtime()*1000000); //生成4位数字 for($i=0;$i<4;$i++){ $font = ImageColorAllocate($im, rand(100,255),rand(0,100),rand(100,255)); // 生成随机颜色 $authnum=rand(1,9); $vcodes.=$authnum; imagestring($im, 5, 2+$i*10, 1, $authnum, $font); } $_SESSION['VCODE'] = $vcodes; for($i=0;$i<100;$i++) //加入干扰象素 { $randcolor = ImageColorallocate($im,rand(0,255),rand(0,255),rand(0,255)); imagesetpixel($im, rand()%70 , rand()%30 , $randcolor); // 画像素点函数 } ImagePNG($im); ImageDestroy($im);?> |
登陆页面验证码代码块
<tr> <td height="30" align="center" class="ziti">验证码:</td> <td width="56"><input type="text" name="checks" id="checks" size="8" height="20"/></td> <td width="178"><img src="checks.php" style="cursor:pointer" onClick="this.src=this.src+'?'+Math.random();"/></td> </tr> |
onClick="this.src=this.src+'?'+Math.random()"
这两个属性实现单击验证码刷新,不需要刷新整个页面
點擊查看更多內容
為 TA 點贊
評論
評論
共同學習,寫下你的評論
評論加載中...
作者其他優質文章
正在加載中
感謝您的支持,我會繼續努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦