DDR爱好者之家 Design By 杰米

本文实例为大家分享了php点击可刷新验证码的具体代码,供大家参考,具体内容如下

验证码类文件 CreateImg.class.php

<"Content-type: image/png"); 
} 
 
private function createCode() 
{ 
 $this->checkcode = strtoupper(substr(md5(rand()),0,$this->codenum)); 
} 
 
private function createImage() 
{ 
 $this->checkimage = @imagecreate($this->width,$this->height); 
 $back = imagecolorallocate($this->checkimage,255,255,255); 
 $border = imagecolorallocate($this->checkimage,0,0,0); 
 imagefilledrectangle($this->checkimage,0,0,$this->width - 1,$this->height - 1,$back); // 白色底 
 imagerectangle($this->checkimage,0,0,$this->width - 1,$this->height - 1,$border); // 黑色边框 
} 
 
private function setDisturbColor() 
{ 
 for ($i=0;$i<=200;$i++) 
 { 
 $this->disturbColor = imagecolorallocate($this->checkimage, rand(0,255), rand(0,255), rand(0,255)); 
 imagesetpixel($this->checkimage,rand(2,128),rand(2,38),$this->disturbColor); 
 } 
} 
 
private function writeCheckCodeToImage() 
{ 
 for ($i=0;$i<=$this->codenum;$i++) 
 { 
 $bg_color = imagecolorallocate ($this->checkimage, rand(0,255), rand(0,128), rand(0,255)); 
 $x = floor($this->width/$this->codenum)*$i; 
 $y = rand(0,$this->height-15); 
 imagechar ($this->checkimage, rand(5,8), $x, $y, $this->checkcode[$i], $bg_color); 
 } 
} 
function __destruct() 
{ 
 unset($this->width,$this->height,$this->codenum); 
} 
} 
"htmlcode">
<"htmlcode">
"content-type" content="text/html;charset=utf-8"> 
<script language="javascript"> 
function newgdcode(obj,url) { 
obj.src = url+ '"imgcode.php" alt="看不清楚,换一张" align="absmiddle" style="cursor: pointer;" onclick="javascript:newgdcode(this,this.src);" /> 
<form method="POST" name="form1" action="image.php"> 
<input type="text" name="test"> 
<br /> 
<input type="submit" name="submit" value="提交"> 
</form> 
</body> 
</head> 
</html> 

以上就是为大家介绍的php点击验证码即可刷新的全部代码,希望对大家的学习有所帮助。

DDR爱好者之家 Design By 杰米
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
DDR爱好者之家 Design By 杰米