高手帮忙,session问题,急急急!!!!!

w198909253132 2009-07-24 01:59:57
实现的功能是:在别人的网站登录进我的系统。在绘制验证码的php页开起session,然后给别人嵌入登录界面的代码包含绘制验证码页,最后提交到我的系统处理。
遇到的问题是:在火狐里面正常,但ie6,傲游里面输入验证码后提示错误,第二次输入正常进去系统。每次新打开浏览器输入验证码都会报错,第二次正常,现在不知道什么原因。
相关代码:
绘制验证码页:
<?php
header("Content-type: image/PNG");
session_start();//将随机数存入session中
$_SESSION['indexLoginRand']="";
$im = imagecreate(35,15); //制定图片大小

$black = ImageColorAllocate($im, 0,0,0); //设定颜色
$white = ImageColorAllocate($im, 255,255,255);

imagefill($im,0,0,$white); //区域填充

$authnum = rand(1000,9999);
//将四位整数验证码绘入图片
$_SESSION['indexLoginRand']=$authnum;
imagestring($im, 5, 0, -1, $authnum, $black);

for($i=0;$i<100;$i++) //加入干扰象素
{
$randcolor = ImageColorallocate($im,rand(0,255),rand(0,255),rand(0,255));
imagesetpixel($im, rand()%70 , rand()%30 , $randcolor);
}

ImagePNG($im);
ImageDestroy($im);
?>


嵌入登录页面:
<form action="http://" method="post">
<div align="center"><font class="black9">分机号 </font>
<INPUT name="ci_fax" type="text" class="input">
<br>
<font class="black9">密 码 </font>
<INPUT name="ci_loginpwd" type="password" class="input">
<br>
<font class="black9">验证码 </font>
<INPUT name="ci_rand" type="text" class="input_rand">
<img src="绘制验证码页"><br>
<INPUT name="user_login" type="submit" value="登 陆" class="inputbt">
  
<!--此处的“value”填写返回页面完整地址,用户登录时,填写的分机号码、密码、验证码有错误时,将返回这个页面-->
<input type="hidden" name="url" value="">
<INPUT type="button" value="注 册" onClick="location.replace('http://ip/reg.php?agent=1321');" class="inputbt">
<br>
<a href="http:///getpassword.php">忘记密码</a>  <a href="http:///realcheck.php" >真实验证</a>
</div>
</form>

帮我解决问题的送上100分,在线等!!
...全文
236 30 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
30 条回复
切换为时间正序
请发表友善的回复…
发表回复
fenyao 2009-07-25
  • 打赏
  • 举报
回复
关注
YHL27 2009-07-25
  • 打赏
  • 举报
回复
顶起!
Ricky_Bobo 2009-07-25
  • 打赏
  • 举报
回复
你看一下,你页换显示的验证码和你session中存的是一个值吗?
forandever 2009-07-25
  • 打赏
  • 举报
回复
步骤:
1、php 页面里加入清除缓存的代码,上面有人回复了这个代码
2、这里修改一下

<font class="black9">验证码 </font>
<INPUT name="ci_rand" type="text" class="input_rand">
<img src="绘制验证码页"> <br>
修改为:
<font class="black9">验证码 </font>
<INPUT name="ci_rand" type="text" class="input_rand">
<img src="绘制验证码页?r=<?php echo rand(0,100)?>"> <br>
fkueso 2009-07-25
  • 打赏
  • 举报
回复
提交页面是不是session没有启动啊!
isset($_SESSION['indexLoginRand'])看一下;

echo $ci_rand;
echo $ci_rand_system;
对比一下不就清楚了!
foolbirdflyfirst 2009-07-24
  • 打赏
  • 举报
回复
[Quote=引用 22 楼 w198909253132 的回复:]
PHP code<?phprequire_once ("../bin/db.php");$ci_fax=trim($_POST['ci_fax']);$ci_loginpwd=strtoupper(md5($_POST['ci_loginpwd']));$ci_rand=trim($_POST['ci_rand']);$return_url=$_POST['url'];$ci_rand_system=$_SESSION['indexLoginRand'];if (strcmp($ci_rand,$ci_rand_system)!=0) {session_unregister('indexLoginRand');echo"<script>alert(\"验证码输入错误,请重新输入!\");location.replace('$return_url');</script>";}
部分后台源代码 各位大侠参考下,总弹出验证码错误,重新输入
[/Quote]
你就直接比较下$ci_rand,$ci_rand_system
,看ie6下有问题的那次验证码提交,究竟是这两个东西都是什么样的值。
x198909253132 2009-07-24
  • 打赏
  • 举报
回复
.
yunfeifan 2009-07-24
  • 打赏
  • 举报
回复
你比较两个页面的session 结果,看看有什么问题?
w198909253132 2009-07-24
  • 打赏
  • 举报
回复

<?php
require_once ("../bin/db.php");
$ci_fax = trim($_POST['ci_fax']);
$ci_loginpwd = strtoupper(md5($_POST['ci_loginpwd']));
$ci_rand = trim($_POST['ci_rand']);
$return_url = $_POST['url'];
$ci_rand_system = $_SESSION['indexLoginRand'];


if (strcmp($ci_rand, $ci_rand_system) != 0) {
session_unregister('indexLoginRand');
echo "<script>alert(\"验证码输入错误,请重新输入!\");location.replace('$return_url');</script>";}

部分后台源代码 各位大侠参考下,总弹出验证码错误,重新输入
w198909253132 2009-07-24
  • 打赏
  • 举报
回复
代码我感觉也没问题,用firefox也没有问题,可是我们经理测试用傲游每次新开浏览器输入的验证码都错误
w198909253132 2009-07-24
  • 打赏
  • 举报
回复
嗯 我用你的代码测试一下看看
程序猿之殇 2009-07-24
  • 打赏
  • 举报
回复
我测试了一下,没有发现任何问题.
session值是能够正确得到的.
可能是你代码哪块有问题.
不知道你是如何验证的.
//code.php

<?php
session_start();//将随机数存入session中
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Content-type: image/PNG");

$_SESSION['indexLoginRand']="";
$im = imagecreate(35,15); //制定图片大小

$black = ImageColorAllocate($im, 0,0,0); //设定颜色
$white = ImageColorAllocate($im, 255,255,255);

imagefill($im,0,0,$white); //区域填充

$authnum = rand(1000,9999);
//将四位整数验证码绘入图片
$_SESSION['indexLoginRand']=$authnum;
imagestring($im, 5, 0, -1, $authnum, $black);

for($i=0;$i <100;$i++) //加入干扰象素
{
$randcolor = ImageColorallocate($im,rand(0,255),rand(0,255),rand(0,255));
imagesetpixel($im, rand()%70 , rand()%30 , $randcolor);
}

ImagePNG($im);
ImageDestroy($im);
?>
//test2.html
<form action="index.php" method="post">
<div align="center"> <font class="black9">分机号 </font>
<INPUT name="ci_fax" type="text" class="input">
<br>
<font class="black9">密 码 </font>
<INPUT name="ci_loginpwd" type="password" class="input">
<br>
<font class="black9">验证码 </font>
<INPUT name="ci_rand" type="text" class="input_rand">
<img src="code.php"> <br>
<INPUT name="user_login" type="submit" value="登 陆" class="inputbt">
  
<!--此处的“value”填写返回页面完整地址,用户登录时,填写的分机号码、密码、验证码有错误时,将返回这个页面-->
<input type="hidden" name="url" value="">
<INPUT type="submit" value="注 册" class="inputbt">
<br>
<a href="http:///getpassword.php">忘记密码 </a>   <a href="http://l/index.php" >真实验证 </a>
</div>
</form>
//index.php
<?php
session_start();
echo $_POST['ci_rand'] . "<br/>";
print_r($_SESSION['indexLoginRand']);
?>
w198909253132 2009-07-24
  • 打赏
  • 举报
回复
不行啊 达人人们 救救 我吧 经理让我今天搞定。。。。。。。
phpboy 2009-07-24
  • 打赏
  • 举报
回复
[Quote=引用 12 楼 w198909253132 的回复:]
<img src="http://www.uufax.com/bin/rand.php?act=yes" onClick="this.src='include/code.php#'+new Date().getTime()">


点完图片结果是一个大红叉
[/Quote]
上面那是我的验证码地址,我晕!
sainer 2009-07-24
  • 打赏
  • 举报
回复
cache 缓存
程序猿之殇 2009-07-24
  • 打赏
  • 举报
回复
cache就是缓存,清除浏览器的缓存再试试效果看行不行.
w198909253132 2009-07-24
  • 打赏
  • 举报
回复
cache 是什么 这个东东我不知道怎么弄啊
程序猿之殇 2009-07-24
  • 打赏
  • 举报
回复
加上,然后清除一下浏览器的cache.呵呵.我只能想到是cache的原因.
w198909253132 2009-07-24
  • 打赏
  • 举报
回复
<img src="http://www.uufax.com/bin/rand.php?act=yes" onClick="this.src='include/code.php#'+new Date().getTime()">


点完图片结果是一个大红叉
phpboy 2009-07-24
  • 打赏
  • 举报
回复

<img src='验证' onClick="this.src='include/code.php#'+new Date().getTime()">

打印出处理页面的
print_r( $_SESSION['indexLoginRand'] );

看一下是什么情况

加载更多回复(10)

21,893

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧