第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

代碼細(xì)節(jié)問(wèn)題,自己做筆記寫(xiě)的,有點(diǎn)問(wèn)題。

captcha.php代碼如下:

session_start();
$image = imagecreatetruecolor( 100, 30 );// 新建一個(gè)真彩色圖像

/**
* imagecolorallocate — 為一幅圖像分配顏色。
* 說(shuō)明:int imagecolorallocate ( resource $image , int $red , int $green , int $blue )
*/
$bgcolor = imagecolorallocate($image,255,255,255);

/**
* imagefill — 區(qū)域填充。
* 說(shuō)明:bool imagefill ( resource $image , int $x , int $y , int $color )
* 在 image 圖像的坐標(biāo) x,y(圖像左上角為 0, 0)處用 color 顏色執(zhí)行區(qū)域填充(即與 x, y 點(diǎn)顏色相同且相鄰的點(diǎn)都會(huì)被填充)。
*/
imagefill( $image, 0, 0, $bgcolor );

/**
* 數(shù)字驗(yàn)證碼的實(shí)現(xiàn):主要用到 imagestring 這個(gè)函數(shù);$i表示驗(yàn)證碼個(gè)數(shù)
*/
//for($i=0; $i<4; $i++){
// ? ?$fontsize = 5;
// ? ?$fontcolor = imagecolorallocate( $image, rand(0,125), rand(0,125), rand(0,125) );
// ? ?$fontcontent = rand(0,9);
// ? ?$fontx = ($i*100/4) + rand(5,10);
// ? ?$fonty = rand(5,10);
//
// ? ?/**
// ? ? * ?bool imagestring ( resource $image , int $font , int $x , int $y , string $s , int $col )
// ? ? * ?用 col 顏色將字符串 s 畫(huà)到 image 所代表的圖像的 x,y 坐標(biāo)處(這是字符串左上角坐標(biāo),整幅圖像的左上角為 0,0)。
// ? ? * ?如果 font 是 1,2,3,4 或 5,則使用內(nèi)置字體
// ? ? */
// ? ?imagestring($image,$fontsize,$fontx,$fonty,$fontcontent,$fontcolor);
//}

/**
* 字母驗(yàn)證碼的實(shí)現(xiàn):主要用到 imagestring 這個(gè)函數(shù);$i表示驗(yàn)證碼個(gè)數(shù)
*/
$captcha_code = '';

for($i=0;$i<4;$i++){
? ?$fontsize = 6;
? ?$fontcolor = imagecolorallocate( $image, rand(0,125), rand(0,125), rand(0,125) );
? ?$date = 'abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ123456789';
? ?$fontcontent = substr($date,rand(0,strlen($date)-1),1);

? ?$captcha_code .= $fontcontent;

? ?$fontx = ($i*100/4) + rand(5,10);
? ?$fonty = rand(5,10);

? ?/**
? ? * ?bool imagestring ( resource $image , int $font , int $x , int $y , string $s , int $col )
? ? * ?用 col 顏色將字符串 s 畫(huà)到 image 所代表的圖像的 x,y 坐標(biāo)處(這是字符串左上角坐標(biāo),整幅圖像的左上角為 0,0)。
? ? * ?如果 font 是 1,2,3,4 或 5,則使用內(nèi)置字體
? ? */
? ?imagestring($image,$fontsize,$fontx,$fonty,$fontcontent,$fontcolor);
}
$_SESSION['authcode'] = $captcha_code;

/**
* 驗(yàn)證碼點(diǎn)干擾元素的實(shí)現(xiàn):主要用到 imagesetpixel 函數(shù);$i 表示干擾元素個(gè)數(shù)
*/
for($i=0;$i<200;$i++){
? ?$pointcolor = imagecolorallocate( $image, rand(50,200), rand(50,200), rand(50,200) );
? ?/**
? ? * bool imagestring ( resource $image , int $font , int $x , int $y , string $s , int $col )
? ? * 用 col 顏色將字符串 s 畫(huà)到 image 所代表的圖像的 x,y 坐標(biāo)處(這是字符串左上角坐標(biāo),整幅圖像的左上角為 0,0)。
? ? * 如果 font 是 1,2,3,4 或 5,則使用內(nèi)置字體。
? ? */
? ?imagesetpixel( $image,rand(1,99),rand(1,99),$pointcolor);
}

/**
* 驗(yàn)證碼線干擾元素的實(shí)現(xiàn):主要用到 imageline 函數(shù):$i表示線的條數(shù)。
*/
for($i=0;$i<4;$i++){
? ?$linecolor = imagecolorallocate( $image, rand(80,220), rand(80,220), rand(80,220) );
? ?/**
? ? * ?bool imageline ( resource $image , int $x1 , int $y1 , int $x2 , int $y2 , int $color )
? ? * ?用 color 顏色在圖像 image 中從坐標(biāo) x1,y1 到 x2,y2(圖像左上角為 0, 0)畫(huà)一條線段。
? ? */
? ?imageline( $image, rand(1,99), rand(1,29), rand(1,99), rand(1,29), $linecolor);
}

header('content-type:image/png');

imagepng( $image );//imagepng — 以 PNG 格式將圖像輸出到瀏覽器或文件

imagedestroy( $image );//imagedestroy — 銷毀一圖像



from.php代碼如下:

<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2017/3/18
* Time: 9:34
*/
header("Content-type:text/html;charset=utf-8");
if(isset($_REQUEST["authcode"])){
? ?print_r($_REQUEST["authcode"]);
session_start();
print_r($_SESSION["authcode"]);
if( strtolower($_REQUEST["authcode"]) == $_SESSION["authcode"] ){
echo "1";
}else{
echo "0";
}
// ? ?if ($_REQUEST["authcode"] == $_SESSION["authcode"])
// ? ?{
// ? ? ? ?header("Content-type: text/html; charset=UTF8");
// ? ? ? ?echo "<h5 color="#0000CC">輸入正確</h5>";
// ? ?}else{
// ? ? ? ?header("Content-type: text/html; charset=UTF8");
// ? ? ? ?echo "<h5 color="#CC0000">輸入錯(cuò)誤</h5>";
// ? ? ? ?echo $_REQUEST["authcode"];
// ? ?}
exit;
}
?>

<!doctype html>
<html lang="en">
<head>
? ?<meta charset="UTF-8">
? ?<title>確認(rèn)驗(yàn)證碼</title>
</head>

<body>
<form method="post" action="./from.php">
? ?<p>驗(yàn)證碼圖片:<img border="1" src="./captcha.php/r=<?php echo rand();?>" width=100,height=30";</p>
? ?<p>請(qǐng)輸入圖片中的內(nèi)容:<input type="text" name="authcode" value=""></p>
? ?<p><input type="submit" value="提交" style="padding:6px 20px;"></p>
</form>
</body>
</html>



具體不清楚哪兒有問(wèn)題,驗(yàn)證信息的時(shí)候,兩個(gè)數(shù)據(jù)都是一樣的, 可是輸出去卻總是“0”,當(dāng)局者迷,旁觀者清。求大神幫忙看下~謝謝!

正在回答

1 回答

曉得是什么原因了~

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

Momo_____

可以告訴我為什么嗎?我的代碼也出現(xiàn)了這種問(wèn)題QWQ
2017-06-07 回復(fù) 有任何疑惑可以回復(fù)我~
#2

Only_L 提問(wèn)者 回復(fù) Momo_____

還沒(méi)解決嗎?要是沒(méi)解決,我下班回家的時(shí)候把代碼拿出來(lái)給你看看。這很久之前的了,我都不知道哪出錯(cuò)了,回頭看看程序筆記。
2017-06-13 回復(fù) 有任何疑惑可以回復(fù)我~
#3

Momo_____ 回復(fù) Only_L 提問(wèn)者

嘻嘻,再不需要啦,從網(wǎng)上找了一點(diǎn),結(jié)果成功啦,謝謝你吖
2017-06-17 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消
PHP實(shí)現(xiàn)驗(yàn)證碼制作
  • 參與學(xué)習(xí)       37930    人
  • 解答問(wèn)題       338    個(gè)

各種形態(tài)驗(yàn)證碼核心原理與實(shí)現(xiàn)技巧,講解實(shí)現(xiàn)過(guò)程中的技術(shù)難點(diǎn)

進(jìn)入課程

代碼細(xì)節(jié)問(wèn)題,自己做筆記寫(xiě)的,有點(diǎn)問(wèn)題。

我要回答 關(guān)注問(wèn)題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)