-
中文驗證查看全部
-
<?php $image = imagecreatetruecolor( 100, 30 ); $bgcolor = imagecolorallocate( $image, 255, 255, 255 ); imagefill( $image, 0, 0, $bgcolor ); // 創(chuàng)建一個循環(huán),循環(huán)200次 // 在循環(huán)內(nèi),用GD庫生成一個隨機(jī)顏色 // 在隨機(jī)位置上畫一個干擾點,顏色使用上面的隨機(jī)顏色 for($i=0;$i<200;$i++){ $dot= imagecolorallocate($image,rand(50,200),rand(50,200),rand(50,200)); imagesetpixel($image,rand(1,99),rand(1,29),$dot); } header( 'content-type: image/png' ); imagepng( $image ); imagedestroy( $image );查看全部
-
當(dāng)驗證信息看不清的時候需要用到j(luò)s動態(tài)校驗 實現(xiàn)動態(tài)驗證: 1、增加可點擊的“換一個”文案 2、用js選取器選取驗證碼圖片 3、用js修改驗證碼圖片地址(改src)查看全部
-
form.php代碼 <?php header('content-type:text/html;charset=utf-8'); if(isset($_REQUEST['authcode'])){ session_start(); if(strtolower($_REQUEST['authcode'])==$_SESSION['authcode']){ echo '<font color="#0000CC">輸入正確</font>'; }else{ echo '<font color="#CC0000"> <b>輸入錯誤</b> </font>'; } exit(); } ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>確認(rèn)驗證碼</title> </head> <body> <form method="post" action="./form.php"> <p>驗證碼圖片:<img border="1" src="./captcha.php?r=<?php echo rand();?>" width:100px; height:30px" /> <p>請輸入圖片中的內(nèi)容:<input type="text" name="authcode" value="" /></p> <p><input type="submit" value="提交" ></p> </form> </body> </html>查看全部
-
數(shù)字字母混合驗證碼,用到了substr()截取字符串的函數(shù) for($i=0;$i<4;$i++){ $fontsize=6; $fontcolor=imagecolorallocate($image, rand(0,120),rand(0,120), rand(0,120)); $data="abcdefghijklmnopqrstuvwxyz123456789"; $fontcontent=substr($data,rand(0,strlen($data)),1); $x=($i*100/4)+rand(5,10); $y=rand(5,10); imagestring($image, $fontsize, $x, $y, $fontcontent, $fontcolor);查看全部
-
往畫布中添加干擾元素 imagestring水平畫一行字符 imagestring($image,int $front,$x,$y,strintg $s,int $con1)字體干擾 imagesetpixel($image,$x,$y,int $col) 一個點需要一個坐標(biāo),點干擾 imageline($iamge,$x,$y,$x1,$y1,$col) 線段是兩個點,所以設(shè)兩個坐標(biāo),線干擾查看全部
-
1.創(chuàng)建畫布 imagecreatetrueccolor(100,230)[默認(rèn)黑色的] 2.設(shè)置背景色取代黑色默認(rèn)顏色imagecolorallocate($image,rgb(0到255的值),rgb(0到255的值,rgb(0到255的值) 3.填充背景色到畫布上 imagefill() 4.為空白畫布上添加字符 imagestring() 生成數(shù)字等 5.添加點干擾元素 imagesetpixel() 生成點或者線干擾查看全部
-
<?php $image = imagecreatetruecolor(100,50); //生成一張100*50大小的圖片(底圖) header("content-type:image/png"); //定義圖片格式為png 注意header一定要在image輸出圖像之前 $bgcolor = imagecolorallocate($image,200,200,200); //為一幅圖分配顏色 imagefill($image,0,0,$bgcolor); //將顏色填充到底圖上 imagepng($image); //區(qū)域填充 imagedestroy($image); //銷毀資源,便于回收查看全部
-
需要的技術(shù): ASCII碼理論, UTF-8編碼理論 SESSION基礎(chǔ) 前端Ajax基礎(chǔ):內(nèi)容的校驗查看全部
-
因為讀操作不會對數(shù)據(jù)產(chǎn)生影響,可以同時多個線程進(jìn)行互不干擾,但是寫數(shù)據(jù)的話就得進(jìn)行加鎖,也就是一個線程在操作時候,要保證其他線程不能同時對資源進(jìn)行操作,不然最后數(shù)據(jù)就會發(fā)生錯誤,根據(jù)數(shù)據(jù)庫引擎的加鎖方式不同,可能有字段加鎖,表加鎖,開銷也會不同,另外當(dāng)數(shù)據(jù)量很大時候,根據(jù)存儲結(jié)構(gòu)不同,可能寫入一個數(shù)據(jù),會進(jìn)行很大的數(shù)據(jù)變動,這時候就會比較消耗資源查看全部
-
老師講的真不錯,一聽就懂了查看全部
-
圖片驗證碼查看全部
-
captcha.php代碼: <?php session_start(); $image = imagecreatetruecolor( 100,30 ); $bgcolor = imagecolorallocate($image,255,255,255); imagefill($image,0,0,$bgcolor); for($i=0;$i<200;$i++){ $pointcolor = imagecolorallocate($image,rand(50,200),rand(50,200),rand(50,200)); imagesetpixel($image,rand(1,99),rand(1,99),$pointcolor); } for($i=0;$i<3;$i++){ $linecolor = imagecolorallocate($image,rand(80,220),rand(80,220),rand(80,220)); } $captch_code = ''; for($i=0;$i<4;$i++){ $fontsize = 6; $fontcolor = imagecolorallocate($image,rand(0,120),rand(0,120),rand(0,120)); $data = 'abcdefghijkmnpqrstuvwxy3456789'; $fontcontent = substr($data,rand(0,strlen($data)-1),1); $captch_code.=$fontcontent; $x = ($i*100/4) + rand(5,10); $y = rand(5,10); imagestring($image,$fontsize,$x,$y,$fontcontent,$fontcolor); } header('content-type:image/png'); imagepng($image); $_SESSION['authcode'] = $captch_code; ?>查看全部
-
form.php代碼 <?php header('content-type:text/html;charset=utf-8'); if(isset($_REQUEST['authcode'])){ session_start(); if(strtolower($_REQUEST['authcode'])==$_SESSION['authcode']){ echo '<font color="#0000CC">輸入正確</font>'; }else{ echo '<font color="#CC0000"> <b>輸入錯誤</b> </font>'; } exit(); } ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>確認(rèn)驗證碼</title> </head> <body> <form method="post" action="./form.php"> <p>驗證碼圖片:<img border="1" src="./captcha.php?r=<?php echo rand();?>" width:100px; height:30px" /> <p>請輸入圖片中的內(nèi)容:<input type="text" name="authcode" value"" /></p> <p><input type="submit" value="提交" ></p> </form> </body> </html>查看全部
-
驗證碼步驟查看全部
舉報
0/150
提交
取消