【发布时间】:2011-01-08 15:31:12
【问题描述】:
我遇到了验证码问题。在我提供验证码后,在我的联系我们表单中显示错误的验证码。我该如何解决这个问题
header('Content-type: image/jpeg');
$width = 50;
$height = 24;
$my_image = imagecreatetruecolor($width, $height);
imagefill($my_image, 0, 0, 0xFFFFFF);
// add noise
for ($c = 0; $c < 40; $c++){
$x = rand(0,$width-1);
$y = rand(0,$height-1);
imagesetpixel($my_image, $x, $y, 0x000000);
}
$x = rand(1,10);
$y = rand(1,10);
$rand_string = rand(1000,9999);
imagestring($my_image, 5, $x, $y, $rand_string, 0x000000);
setcookie('tntcon',(md5($rand_string).'a4xn'));
imagejpeg($my_image);
imagedestroy($my_image);
?>
这是我的 js 验证
if(document.getElementById("captcha").value==""){
alert("Please type the code shown ");
document.getElementById("captcha").value="";
document.getElementById("captcha").focus();
return false;
}
谁能说说它有什么问题。谢谢在adv
【问题讨论】:
标签: php javascript jquery html css