我就想知道怎么能做出来,只要能和PHP的登录界面放在一起就行

解决方案 »

  1.   

    验证码生成:
    <?php
    $num="";
    for($i=0;$i<4;$i++){
    $num.=rand(0,9);
    }
    Session_start();
    $_SESSION["Checknum"]=$num;
    Header("Content-typt:image/PNG");
    $im=imagecreate(60,20);
    $black=ImageColorAllocate($im,0,0,0);
    $gray=ImageColorAllocate($im,200,200,200);
    imagefill($im,0,0,$gray);
    $style=array($black,$black,$black,$black,$black,$gray,$gray,$gray,$gray,$gray);
    imagesetstyle($im,$style);
    $y1=rand(0,20);
    $y2=rand(0,20);
    $y3=rand(0,20);
    $y4=rand(0,20);
    imageline($im,0,$y1,60,$y3,IMG_COLOR_STYLED);
    imageline($im,0,$y2,60,$y4,IMG_COLOR_STYLED);
    for($i=0;$i<80;$i++){
    imagesetpixel($im,rand(0,60),rand(0,20),$black);
    }
    $setx=rand(8,15);
    for($i=0;$i<4;$i++){
    $strpos=rand(1,6);
    imagestring($im,5,$strx,$strpos,substr($num,$i,1),$black);
    $strx+=rand(12,18);
    }
    ImagePNG($im);
    ImageDestroy($im);
    ?>输入验证码:
    <html>
    <head>
    <title>test</title>
    </head>
    <body>
    <form action="t3.php" method="post">
    <img src="t1.php">
    <a href="t2.php">换一个</a>
    <input type="text" name="password"><br>
    <input type="submit" value="确定">
    </form>
    </body>
    </html>结果:
    <?php
    Session_start();
    $pass1=$_POST["password"];
    $pass2=$_SESSION["Checknum"];
    if($pass1==$pass2){
    echo "验证通过";
    }else{
    echo  "验证失败";
    }
    ?>
      

  2.   

    要开启GD库支持你可以phpinfo();察看是否开启了
      

  3.   

    看http://blog.csdn.net/luojxun/archive/2008/09/27/2979694.aspx