本帖最后由 yjs901 于 2009-07-13 14:18:24 编辑

解决方案 »

  1.   

    验证码页面 代码
    <?php 
        session_start();
        unset($str); //删除每次刷新前的字符串;
        Header("Content-type: image/png"); 
        $a=range(0,9);
        $b=range(a,z);
        $c=range(A,Z);
        $d=array_merge($a,$b,$c);
         for( $i=0; $i<4; $i++ )
         {
             $x= rand(0,61);
             $str .= $d[$x];
        }
    $str=strtolower($str);
         //print_r($str);exit; 
         $_SESSION['authnum']=$str;
         $img = imagecreate(70,30);
         $bgcolor= imagecolorallocate($img,136,193,255); //背景色;
         $foot= imagecolorallocate($img,255,90,145); //字体色;
         $rand= imagecolorallocate($img,255,150,50); //干扰色;
         imagestring($img,5,10,5,$str,$foot); //把字符串写在图上;
        for( $i=0; $i<=60; $i++)
         {
             imagesetpixel($img, rand(0,70), rand(0,30), $rand); //循环干扰点的元素;
         }
         imageline( $img, rand(0,70), rand(0,30), rand(0,70), rand(0,30), $rand);//在图象上画直线;
         imagepng( $img ); //输出图象;
         imagedestroy( $img ); //销毁图象
     ?>
      

  2.   

    这个判断if(strtolower($CheckCode)!=$_SESSION['authnum'])
    总是true?
      

  3.   

    echo strtolower($CheckCode)出来的值是什么啊?
      

  4.   

    我知道这个函数是这个意思,我的意思是说把它和session echo出来
      

  5.   


    echo strtolower($CheckCode)出来的值 是输入的值
    echo $_SESSION['authnum']出来的值 却为空。
      

  6.   

    echo $_SESSION['authnum']出来的值 却为空。说明你创建验证码的时候没把验证码写入session啊
    在你创建验证码那个程序里加上这几句session_start();
    $_SESSION['authnum'] = (产生的验证码的值);这样session就不会为空了
      

  7.   

    你看嘛,是写了的。
    <?php 
        session_start();
        unset($str); //删除每次刷新前的字符串;
        Header("Content-type: image/png"); 
        $a=range(0,9);
        $b=range(a,z);
        $c=range(A,Z);
        $d=array_merge($a,$b,$c);
         for( $i=0; $i<4; $i++ )
         {
             $x= rand(0,61);
             $str .= $d[$x];
        }
        $str=strtolower($str);
         //print_r($str);exit; 
         $_SESSION['authnum']=$str;
         $img = imagecreate(70,30);
         $bgcolor= imagecolorallocate($img,136,193,255); //背景色;
         $foot= imagecolorallocate($img,255,90,145); //字体色;
         $rand= imagecolorallocate($img,255,150,50); //干扰色;
         imagestring($img,5,10,5,$str,$foot); //把字符串写在图上;
        for( $i=0; $i<=60; $i++)
         {
             imagesetpixel($img, rand(0,70), rand(0,30), $rand); //循环干扰点的元素;
         }
         imageline( $img, rand(0,70), rand(0,30), rand(0,70), rand(0,30), $rand);//在图象上画直线;
         imagepng( $img ); //输出图象;
         imagedestroy( $img ); //销毁图象
     ?>
      

  8.   

     //print_r($str);exit; 
     
    不知道你这边打印出来了没 要是这边可以打出来的话 
    就是你验证strtolower($CheckCode)!=$_SESSION['authnum'] 这个的时候 SESSION没开启吧
      

  9.   


    print_r($str) 可以打出来, 验证页面最上面第一行代码就开启SESSION了啊  session_start();
      

  10.   

    session配置是不是有问题?
    session里是空的话,在生成验证码的时候 没有保存上。 
    你看看你的session是不是好的,
    做两个测试网页,第一个里设置session,然后再第二个网页里显示这个session。
      

  11.   

    调试方式:先直接对$_SESSION["authnum"]赋值,看看在提交验证时能否打印出来的$_SESSION["authnum"]结果
      

  12.   

    最好先注册这具SESSION变量。
    session_register("authnum")
    $_SESSION["authnum"]=值
      

  13.   

    我这样调试的,abc.php代码是:
    <?php 
    session_start();
     $_SESSION['authnum']='123456';?>bcd.php代码是:
    <?php 
      session_start();
      echo $_SESSION['authnum'];?>结果还是为空,看了下,SESSION文件是产生了的。
      

  14.   

    你这个问题是这样的 你输入的验证码的值 与session中的值比较时其实是 与 上一次 生成图片中的值比较   这就是 不同步问题 我也遇到了 不知道该怎么样解决  可以加我 msn chen1706#gmail.com (@)  一起讨论讨论