這是利用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 />
如下圖所示:
相關(guān)推薦:
php點(diǎn)擊驗(yàn)證碼實(shí)時(shí)刷新的實(shí)現(xiàn)代碼
以上就是PHP實(shí)現(xiàn)點(diǎn)擊驗(yàn)證碼或看不清會(huì)刷新驗(yàn)證碼的詳細(xì)內(nèi)容,更多請(qǐng)關(guān)注 其它相關(guān)文章!
鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。
新聞熱點(diǎn)
疑難解答
圖片精選