幫我看一下哪裡錯了,怎麼輸都是顯示輸入錯誤

來源:互聯網
上載者:User











03.php
session_start();
function a($type, $length ,$clear){
$nums=range(0,9);
$xxzm=range('a','z');
$dxzm=range('A','Z');
$igorne=array('0','o','1','l');
$chars=array();
if($type==1)
$chars=$nums;
if($type==2)
$chars=array_merge($nums,$xxzm);
if($type==3)
$chars=array_merge($nums,$xxzm,$dxzm);
if($clear==true)
$chars=array_diff($chars,$igorne);
$keys=array_rand($chars,$length);
$code="";
foreach($keys as $key)
$code=$code.$chars[$key];
return $code;

}

$yzm=a(3,5,true);
$_SESSION['yzm']=$yzm;
echo $yzm;
?>


回複討論(解決方案)

你在程式檔案的開始處 和 接收提交的程式碼片段中列印出 $_SESSION['yzm'] 和 $_POST['check'] 就會知道問題的所在了

require('03.php'); //產生驗證碼,並儲存於 $_SESSION
而 $checkstr=$_SESSION['yzm']; //使用$_SESSION變數擷取EX4_14_image.php頁面上的驗證碼
總是在其後運行,顯然獲得的只是最新設定的內容

要怎麼改呢?

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.