亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

點擊 input 提交驗證后只是刷新了頁面,沒有提示錯誤信息。

captcha.php 代碼:

<?php
session_start();
$width?=?100;
$height?=?40;
//?創建圖像
$image?=?imagecreatetruecolor($width,?$height);
//?白色背景
$bgcolor?=?imagecolorallocate($image,?255,?255,?255);
imagefill($image,?0,?0,?$bgcolor);
$captch_code?=?'';
//?隨機生成4位字母、數字組合
for?($i=0;?$i?<?4;?$i++)?{
????$fontsize?=?8;
????$fontcolor?=?imagecolorallocate($image,?mt_rand(0,120),?mt_rand(0,120),?mt_rand(0,120));
????$data?=?'abcdefghjkmnpqrstvwxyz23456789';
????$fontcontent?=?substr($data,?mt_rand(0,?strlen($data)),?1);
????$captch_code?.=?$fontcontent;
????$x?=?($i*100?/?4)?+?mt_rand(5,?10);
????$y?=?mt_rand(5,?10);
????imagestring($image,?$fontsize,?$x,?$y,?$fontcontent,?$fontcolor);
}
$_SESSION['authcode']?=?$captch_code;
//?生成干擾點
for?($i=0;?$i?<?200;?$i++)?{
????$pointcolor?=?imagecolorallocate($image,?mt_rand(50,200),?mt_rand(50,200),?mt_rand(50,200));
????imagesetpixel($image,?mt_rand(1,99),?mt_rand(1,39),?$pointcolor);
}
//?生成干擾線
for?($i=0;?$i?<?3;?$i++)?{
????$linecolor?=?imagecolorallocate($image,?mt_rand(80,220),?mt_rand(80,220),?mt_rand(80,220));
????imageline($image,?mt_rand(1,99),?mt_rand(1,39),?mt_rand(1,99),?mt_rand(1,39),?$linecolor);
}
header('Content-Type:image/png');
imagepng($image);
//?及時銷毀圖像
imagedestroy($image);

form.php 代碼:

<?phpif?(isset($REQUEST['authcode']))?{
????session_start();
????if?(strtolower($_REQUEST['authcode'])?==?$_SESSION['authcode'])?{
????????echo?'輸入正確!';
????}?else?{
????????echo?'輸入錯誤,請返回重試。';
????}
????exit();
}?><!DOCTYPE?html>
<html>
<head>
????<meta?charset="UTF-8">
????<title>Document</title>
</head>
<body>
????<form?method="post"?action="form.php">
????????<img?id="captcha_img"?src="captcha.php?r=<?php?echo?rand();?>"?width="100"?height="40"?alt="">
????????<p><a?href="javascript:void(0)"?onclick="document.getElementById('captcha_img').src='captcha.php?r='+Math.random()">看不清?換一張</a></p>
????????<input?type="text"?name="authcode"?value=""?placeholder="請輸入圖片中的內容">
????????<input?type="submit"?value="提交">
????</form>
</body>
</html>


正在回答

1 回答

from.php

第一行變量輸入錯誤,應該是:$_REQUEST。

0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

點擊 input 提交驗證后只是刷新了頁面,沒有提示錯誤信息。

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號