想用php做一個能生成驗證碼的登陸界面,可是查過很多的資料,依然沒有解決問題,總是不能顯示圖片,系統已經有安裝了gd-2.0.28-4,請高手指點如何才能正確顯示圖片呢?
    <?php 
    session_start(); 
    srand((double)microtime()*1000000);    //验证用户输入是否和验证码一致 
        if(isset($HTTP_POST_VARS['authinput']))  
        { 
                if(strcmp($HTTP_POST_VARS['authnum'],$HTTP_POST_VARS['authinput'])==0) 
                        echo "验证成功!"; 
                else 
                        echo "验证失败!"; 
        } 
    
   //生成新的四位整数验证码 
        while(($authnum=rand()%10000)<1000);  
    ?> 
        <form action=authpage.php method=post> 
        <table> 
                请输入验证码:<input type=text name=authinput style="width: 80px"><br> 
                <input type=submit name="验证" value="提交验证码"> 
                <input type=hidden name=authnum value=<? echo $authnum; ?>> 
                <img src=authimg.php?authnum=<? echo $authnum; ?>> 
        </table> 
        </form>

解决方案 »

  1.   

    authimg.php这个的代码是什么?<input type=hidden name=authnum value=<? echo $authnum; ?>>
    把验证码放在这儿不行,要存放在cookie/session中,不然没有意义了
      

  2.   

    把将字符串写入图片的代码贴出来看看.
    另外同楼上的楼上,验证码放在$_SESSION里面,不要放在hidden域发送.
      

  3.   

    你有用GD库么?比如imagecreate?还有你header写对了么?
      

  4.   

    authimg.php页面代码贴出来看一下