課程
/后端開發(fā)
/PHP
/手把手教你實現(xiàn)電商網(wǎng)站后臺開發(fā)
echo出來的只有驗證碼產(chǎn)生的最后一個數(shù)字,$_SESSION['name']放在for里面外面都是這樣
2016-11-28
源自:手把手教你實現(xiàn)電商網(wǎng)站后臺開發(fā) 2-3
正在回答
<?phpob_start();session_start();$image=imagecreatetruecolor(100,30);$fillcolor=imagecolorallocate($image,255,255,255);imagefill($image,0,0,$fillcolor);//生成文字;for($i=0;$i<4;$i++){$size=rand(15,25);$angle=rand(-10,10);$textx=rand(5+$i*$size,5+$i*$size);$texty=rand(18,25);$textcolor=imagecolorallocate($image,rand(50,120),rand(50,120),rand(50,120));$font="E:/PHP/test/fonts/simkai.ttf";$content=rand(0,9);imagettftext($image,$size,$angle,$textx,$texty,$textcolor,$font,$content);$_SESSION['verify']=$content;}/* $_SESSION['verify']=$content; */
//生成干擾點for($i=0;$i<200;$i++){$pixcolor=imagecolorallocate($image,rand(150,220),rand(150,220),rand(150,220));imagesetpixel($image,rand(1,99),rand(1,29),$pixcolor);}
header('content-type:image/gif');imagegif($image);imagedestroy($image);
$_SESSION那里放里面外面都一樣。。。搞得我現(xiàn)在驗證碼只能驗證最后一個數(shù)字。。。
把代碼貼出來看看!
舉報
手把手教你用PHP搭建電子商務(wù)平臺,由淺入深教你搭建電商系統(tǒng)
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
2016-11-30
<?php
ob_start();
session_start();
$image=imagecreatetruecolor(100,30);
$fillcolor=imagecolorallocate($image,255,255,255);
imagefill($image,0,0,$fillcolor);
//生成文字;
for($i=0;$i<4;$i++){
$size=rand(15,25);
$angle=rand(-10,10);
$textx=rand(5+$i*$size,5+$i*$size);
$texty=rand(18,25);
$textcolor=imagecolorallocate($image,rand(50,120),rand(50,120),rand(50,120));
$font="E:/PHP/test/fonts/simkai.ttf";
$content=rand(0,9);
imagettftext($image,$size,$angle,$textx,$texty,$textcolor,$font,$content);
$_SESSION['verify']=$content;
}
/* $_SESSION['verify']=$content; */
//生成干擾點
for($i=0;$i<200;$i++){
$pixcolor=imagecolorallocate($image,rand(150,220),rand(150,220),rand(150,220));
imagesetpixel($image,rand(1,99),rand(1,29),$pixcolor);
}
header('content-type:image/gif');
imagegif($image);
imagedestroy($image);
$_SESSION那里放里面外面都一樣。。。搞得我現(xiàn)在驗證碼只能驗證最后一個數(shù)字。。。
2016-11-29
把代碼貼出來看看!