nbsp;html>
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页面上的验证码
总是在其后运行,显然获得的只是最新设置的内容
要怎么改呢?
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn