-
<!DOCTYPEC html> <html> <head> <meta charset = "utf-8"/> <title>確認驗證碼</title> </head> <form method = "post" ation = "./form.php"> <p>驗證圖片:<image border = "1" id = "captcha_img" src = "./captcha.php?r=<?php rand()?>" width = "100" height = "30"> <a href = "javascript:void(0)" onclick = "document.getElementById('captcha_img').src = './captcha.php?r='+Math.random()">換一個?</a></p> <p>請輸入圖片中的內(nèi)容: <input type = "text" name = "authcode" value = ""/></p> <p><input type= "submit" value = "提交" style = "padding:6px 20px;"></p> </form> </body> </html>查看全部
-
/*for($i=0;$i<4;$i++){ $fontsize = 6; $fontcontent = rand(0,9); $fontcolor = imagecolorallocate($image,rand(0,120),rand(0,120),rand(0,120)); $x= ($i*100/4)+rand(5,10); $y= rand(5,10); imagestring($image,$fontsize,$x,$y,$fontcontent,$fontcolor); }*/ 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,29),$pointcolor); } for($i=0;$i<3;$i++){ $linecolor = imagecolorallocate($image,rand(80,200),rand(80,200),rand(80,200)); imageline($image,rand(1,99),rand(1,29),rand(1,99),rand(1,29),$linecolor); } header('content-type:image/png'); imagepng($image); imagedestroy($image); ?>查看全部
-
<?php session_start(); $image =imagecreatetruecolor(100,30); $bgcolor=imagecolorallocate($image,255,255,255); imagefill ($image,0,0,$bgcolor); $captch_code = ""; for($i=0;$i<4;$i++) { $fontsize = 6; $data = "abcdefghijklmnopqrstuvwxyz12345678"; $fontcontent = substr($data,rand(0,strlen($data)),1); $captch_code .=$fontcontent; $fontcolor = imagecolorallocate($image,rand(0,120),rand(0,120),rand(0,120)); $x= ($i*100/4)+rand(5,10); $y= rand(5,10); imagestring($image,$fontsize,$x,$y,$fontcontent,$fontcolor); } $_SESSION['authcode'] = $captch_code;查看全部
-
<?php 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(); } ?> <!DOCTYPEC html> <html> <head> <meta charset = "utf-8"/> <title>確認驗證碼</title> </head> <form method = "post" ation = "./form.php"> <p>驗證圖片:<image border = "1" src = "./captcha.php?r=<?php rand();?>" width = 100></p> <p>請輸入圖片中的內(nèi)容: <input type = "text" name = "authcode" value = ""/></p> <p><input type= "submit" value = "提交" style = "padding:6px 20px;"></p> </form> </body> </html>查看全部
-
驗證碼查看全部
-
scbzyj 服務端業(yè)務:寫請求的消耗要遠遠大于讀請求。 驗證碼作用:人機校驗區(qū)分,防灌水。查看全部
-
imagecreatetruecolor — 新建一個真彩色圖像 imagecolorallocate — 為一幅圖像分配顏色 imagefill — 區(qū)域填充 imagesetpixel — 畫一個單一像素 imageline — 畫一條線段 header('content-type: image/png'); imagepng($image); imagedestroy($image);查看全部
-
imagettftext imagettftext — 用 TrueType 字體向圖像寫入文本 說明 array imagettftext ( resource $image , float $size , float $angle , int $x , int $y , int $color , string $fontfile , string $text ) 使用 TrueType 字體將 指定的 text 寫入圖像。查看全部
-
<?php session_start(); $table = array( 'pic0'=>'貓', 'pic1'=>'狗', 'pic2'=>'蛇', 'pic3'=>'馬' ); $index = rand(0,3); $value = $table['pic'.$index]; $_SESSION['authcode'] = $value; $filename = dirname(__FILE__).'\\pic'.$index.'.jpg'; $contents = file_get_contents($filename); header('content-type:imege/jpg'); echo $contents;查看全部
-
JS實現(xiàn)動態(tài)校驗驗證碼,即用JS修改圖片的 src,為防止緩存使用隨機數(shù)查看全部
-
bool imagesetpixel ( resource $image , int $x , int $y , int $color ) imagesetpixel() 在 image 圖像中用 color 顏色在 x,y 坐標(圖像左上角為 0,0)上畫一個點。查看全部
-
$image=imagecreatetruecolor(width,height) 生成畫布 $background=imagecolorallocate($image,250,250,250) 設置顏色 imagefill($image,0,0,$background) 填充 在header前不能有任何輸出,否則報錯 header("content-type=image/png") 設置格式 imagepng($image) 輸出 imagedestroy($image) 銷毀資源查看全部
-
驗證碼服務的核心技術(shù)分析 a.底圖的實現(xiàn),并且添加干擾元素--依賴PHP圖片處理庫GD,詳情:http://php.net/gd b.生成驗證內(nèi)容--簡單的隨機數(shù)生成,使用PHP函數(shù)mt_rand();隨機數(shù)字+字母生成,需要ASCII碼理論基礎;隨機中文內(nèi)容生成,需要UTF-8編碼理論基礎; c.驗證內(nèi)容保存在服務器端--需要PHP操作Session基礎; d.驗證內(nèi)容的校驗--需要前段Ajax基礎;查看全部
-
服務端性能:寫請求的消耗要遠遠大于讀請求。 驗證碼:人機校驗區(qū)分,防灌水。查看全部
-
驗證碼的設計思路!查看全部
舉報
0/150
提交
取消