We have used Captcha.php on one of our project, it opens in all browsers but we are not able to view in Google chrome Version 22.
Our Captcha script
session_start();
$captcha = new SimpleCaptcha();
$captcha->CreateImage();
class SimpleCaptcha
{
function CreateImage()
{
header("Content-Type: image/jpeg");
$md5 = md5(rand(0,9999));
$pass = substr($md5, 10, 5);
$_SESSION["pass"] = $pass;
$image = ImageCreatetruecolor(100, 20);
$clr_white = ImageColorAllocate($image, 0, 0, 0);
$clr_black = ImageColorAllocate($image, 255, 255, 255);
imagefill($image, 0, 0, $clr_white);
imagefontheight(15);
imagefontwidth(15);
imagestring($image, 5, 30, 3, $pass, $clr_black);
return imagejpeg($image);
imagedestroy($image);
}
}
HTML Implementation
<img src="code/captcha.php" width="100" height="20" alt="Captcha Code"/>
We are not able to view it on Google Chrome. All the browser return the same image.
It may be to do with caching, I've used this a script of mine:
Just that line should be enough.