<?php
Header("Content-type: image/gif");
$border = 0;
$how = 4;
$w = $how*15;
$h = 20;
$fontsize = 12;
$alpha = "12345";
$number = "67890";
$randcode = "";
srand((double)microtime()*1000000);
$im = ImageCreate($w, $h);
$bgcolor = ImageColorAllocate($im, 255, 255, 255);
ImageFill($im, 0, 0, $bgcolor);
if($border){
$black = ImageColorAllocate($im, 0, 0, 0);
ImageRectangle($im, 0, 0, $w-1, $h-1, $black);
}
for($i=0; $i<$how; $i++){
$alpha_or_number = mt_rand(0, 1);
$str = $alpha_or_number ? $alpha : $number;
$which = mt_rand(0, strlen($str)-1);
$code = substr($str, $which, 1);
$j = !$i ? 4 : $j+15;
$color3 = ImageColorAllocate($im, mt_rand(0,100), mt_rand(0,100), mt_rand(0,100));
ImageChar($im, $fontsize, $j, 3, $code, $color3);
$randcode .= $code;
}
for($i=0; $i<5; $i++){
$color1 = ImageColorAllocate($im, mt_rand(0,255), mt_rand(0,255), mt_rand(0,255));
ImageArc($im, mt_rand(-5,$w), mt_rand(-5,$h), mt_rand(20,300), mt_rand(20,200), 33, 22, $color1);
}
for($i=0; $i<$how*10; $i++){
$color2 = ImageColorAllocate($im, mt_rand(0,255), mt_rand(0,255), mt_rand(0,255));
ImageSetPixel($im, mt_rand(0,$w), mt_rand(0,$h), $color2);
}
session_start();
$_SESSION['wfcode'] = $randcode;
ImagePNG($im);
ImageDestroy($im);?><div class="wfbdbox">
<label class="wfbdxx"><em>*</em>验证码</label>
<div class="wftext3box">
<input type="text" name="wfcode" class="wfcode" /><img src="./../public/wfcode.php" height="29" width="70" alt="看不清,请点击刷新" title="看不清,请点击刷新" onClick="this.src=this.src+'?'" />
</div>
</div>
Header("Content-type: image/gif");
$border = 0;
$how = 4;
$w = $how*15;
$h = 20;
$fontsize = 12;
$alpha = "12345";
$number = "67890";
$randcode = "";
srand((double)microtime()*1000000);
$im = ImageCreate($w, $h);
$bgcolor = ImageColorAllocate($im, 255, 255, 255);
ImageFill($im, 0, 0, $bgcolor);
if($border){
$black = ImageColorAllocate($im, 0, 0, 0);
ImageRectangle($im, 0, 0, $w-1, $h-1, $black);
}
for($i=0; $i<$how; $i++){
$alpha_or_number = mt_rand(0, 1);
$str = $alpha_or_number ? $alpha : $number;
$which = mt_rand(0, strlen($str)-1);
$code = substr($str, $which, 1);
$j = !$i ? 4 : $j+15;
$color3 = ImageColorAllocate($im, mt_rand(0,100), mt_rand(0,100), mt_rand(0,100));
ImageChar($im, $fontsize, $j, 3, $code, $color3);
$randcode .= $code;
}
for($i=0; $i<5; $i++){
$color1 = ImageColorAllocate($im, mt_rand(0,255), mt_rand(0,255), mt_rand(0,255));
ImageArc($im, mt_rand(-5,$w), mt_rand(-5,$h), mt_rand(20,300), mt_rand(20,200), 33, 22, $color1);
}
for($i=0; $i<$how*10; $i++){
$color2 = ImageColorAllocate($im, mt_rand(0,255), mt_rand(0,255), mt_rand(0,255));
ImageSetPixel($im, mt_rand(0,$w), mt_rand(0,$h), $color2);
}
session_start();
$_SESSION['wfcode'] = $randcode;
ImagePNG($im);
ImageDestroy($im);?><div class="wfbdbox">
<label class="wfbdxx"><em>*</em>验证码</label>
<div class="wftext3box">
<input type="text" name="wfcode" class="wfcode" /><img src="./../public/wfcode.php" height="29" width="70" alt="看不清,请点击刷新" title="看不清,请点击刷新" onClick="this.src=this.src+'?'" />
</div>
</div>
解决方案 »
- 分城市的分站系统如何建立,求思路
- 谁有PHP+Socket编程例子,最好是服务器端和客户端应答信息互相通信。各位达人请进。。。
- 如何通过 js 或css 禁用遨游 浏览器的图片放大缩小功能
- php伪静态和动态混合使用
- PHP 寻函数名:把url地址问号后面参数拆分为数组返回
- __autoload到底是什么原理
- 如何将字符进行转换,以使从数据库中提出的文本按输入时格式显示
- 参数传递的问题,请帮忙,谢谢!!!
- 关于mp3在线播放
- 请问各位大侠.我想读出一个文本文件的第一行,但这个文件非常大.请问用什么方法效率最高.必给分.
- 寻求帮助 28 30 31月份选择小程序出现错误
- 在一个类里 其中的一个方法如何调用 另一个方法中的属性变量?
你的文件是否有bom头?
如果有请保存为utf-8 no bom格式。
2、比较奇怪的一点,你明明是PNG的图片,header却是image/gif