php设置session验证码图片显示不了,大侠帮帮我

login.php
<html>
。。。。。。。。。。。
<img src="checkCode.php" onclick="this.src='checkCode.php?aa='+Math.random()" /></td></tr><tr><td><input type="submit" value="登录"/></td><td colspan="2"><input type="reset" value="重新填写"/></td></tr><table></form></html>

checkCode.php
<?php
session_start(); $checkCode=""; for($i=0;$i<4;$i++){ $checkCode.=dechex(rand(1,15)); }
//讲随机验证码保存到session中 $_SESSION['myCheckCode']=$checkCode; //创建图片,并把随机数画上去 $img=imagecreatetruecolor(110,50); //背景默认就是黑色 //你可以指定背景颜色 $bgcolor=imagecolorallocate($img,0,0,0); imagefill($img,0,0,$bgcolor); //创建新的颜色 $white=imagecolorallocate($img,255,255,255); $blue=imagecolorallocate($img,0,0,255); $red=imagecolorallocate($img,255,0,0); $green=imagecolorallocate($img,255,0,0);
//画出干扰线段 for($i=0;$i<20;$i++){ //更好的方法是颜色随机 imageline($img,rand(0,110),rand(0,30),rand(0,110),rand(0,30),imagecolorallocate($img,rand(0,255),rand(0,255),rand(0,255))); } //画出噪点,自己画. //for($i=0;$i<10; //把四个随机值画上去 imagestring($img,rand(1,5),rand(2,80),rand(2,10),$checkCode,$white); //如果要使用中文 //array imagefttext ( string $font_file , string $text [, array $extrainfo ] ) //imagettftext($img,15,10,20,25,$white,"STXINWEI.TTF","北京你好"); //输出 header("content-type: image/png"); imagepng($img);
?>
已经在php.ini配置好gd,并且重启了。到底怎么回事

没细看,这块不好调,因为写好了就放那,不常用那些函数,
建议下一个简洁版本的验证码,对照着删减来看,
注意一下BOM头之内的,
温馨提示:答案为网友推荐,仅供参考
第1个回答  2013-05-31

程序没问题


相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网