亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

PHP使用GD庫制作驗(yàn)證碼的方法(點(diǎn)擊驗(yàn)證碼或看不清會刷新驗(yàn)證碼)

 更新時(shí)間:2017年08月15日 14:32:52   作者:ougexingfuba  
這篇文章主要介紹了PHP使用GD庫制作驗(yàn)證碼的方法(點(diǎn)擊驗(yàn)證碼或看不清會刷新驗(yàn)證碼)的相關(guān)資料,需要的朋友可以參考下

這是利用GD庫生成驗(yàn)證碼的頁面

test.PHP

<?php 
header('Content-Type:image/jpeg'); 
 $img = imagecreatetruecolor(100, 40); 
 $black = imagecolorallocate($img, 0x00, 0x00, 0x00); 
 $green = imagecolorallocate($img, 0x00, 0xFF, 0x00); 
 $white = imagecolorallocate($img, 0xFF, 0xFF, 0xFF); 
 imagefill($img,0,0,$white); //生成隨機(jī)的驗(yàn)證碼 
 $code = ''; 
 for($i = 0; $i < 4; $i++) { $code .= rand(0, 9); } 
 imagestring($img, 5, 10, 10, $code, $black); 
 //加入噪點(diǎn)干擾 
 for($i=0;$i<50;$i++) { 
  imagesetpixel($img, rand(0, 100) , rand(0, 100) , $black); 
  imagesetpixel($img, rand(0, 100) , rand(0, 100) , $green); 
 } //輸出驗(yàn)證碼 header("content-type: image/png"); 
 imagepng($img); 
 imagedestroy($img); 
?> 

這是點(diǎn)擊驗(yàn)證碼或看不清之后可實(shí)現(xiàn)局部刷新驗(yàn)證碼

test2.php

<script type="text/javascript"> 
 function shuaxin() 
 { 
  document.getElementById('code').src = "test.php?"+Math.random(); 
 } 
</script> 
<input type="text"><br /> 
<img id="code" src="test.php" onclick="shuaxin()" /> 
<span onclick="shuaxin()">看不清?</span><br /> 

如下圖所示:

總結(jié)

以上所述是小編給大家介紹的PHP使用GD庫制作驗(yàn)證碼的方法(點(diǎn)擊驗(yàn)證碼或看不清會刷新驗(yàn)證碼),希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時(shí)回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!

相關(guān)文章

最新評論