r-it Posted June 12, 2007 Share Posted June 12, 2007 i am baffled with this problem and i don't know what i can do anymore for my captcha script. I have this class to create my captcha: <?php class captcha { var $Length; var $CaptchaString; var $ImageType; var $Font; var $CharWidth; function captcha ($length = 6, $type = 'jpeg', $letter = '') { $this->Length = $length; $this->ImageType = $type; $this->Font = './hurryup.ttf'; $this->CharWidth = 19; if ($letter == '') { $this->StringGen(); } else { $this->Length = strlen($letter); $this->CaptchaString = $letter; } $this->SendHeader(); $this->MakeCaptcha(); } function StringGen () { $uppercase = range('A', 'Z'); $numeric = range(0, 9); $CharPool = array_merge($uppercase, $numeric); $PoolLength = count($CharPool) - 1; for ($i = 0; $i < $this->Length; $i++) { $this->CaptchaString .= $CharPool[mt_rand(0, $PoolLength)]; } } function SendHeader () { switch ($this->ImageType) { case 'jpeg': header('Content-type: image/jpeg'); break; case 'png': header('Content-type: image/png'); break; default: header('Content-type: image/png'); break; } } function MakeCaptcha () { $imagelength = $this->Length * $this->CharWidth + 16; $imageheight = 35; $image = imagecreate($imagelength, $imageheight); $bgcolor = imagecolorallocate($image, 222, 222, 222); $stringcolor = imagecolorallocate($image, 0, 0, 0); $linecolor = imagecolorallocate($image, 0, 0, 0); imagettftext($image, 25, 0, 8, 22, $stringcolor, $this->Font, $this->CaptchaString); switch ($this->ImageType) { case 'jpeg': imagejpeg($image); break; case 'png': imagepng($image); break; default: imagepng($image); break; } } function GetCaptchaString () { return $this->CaptchaString; } } ?> and this is to store the string in a session <?php ob_start(); //Start the session session_start(); //Load the Class require('./captcha.class.php'); //Create a CAPTCHA $captcha = new captcha(); //Store the String in a session $_SESSION['CAPTCHAString'] = $captcha->GetCaptchaString(); ?> and this is wt i use to get the show the image $img = "<img src=\"./captcha.php\" alt=\"Security code\" width=\"130\" height=\"35\" id=\"captcha\" />"; and its shoeing this image only after i right click and say show picture. I am using innerhtml to get this and its not showing any image in fact, i really do not know why, has anyone experienced a similar problem in ie? Link to comment https://forums.phpfreaks.com/topic/55244-solved-image-only-works-after-right-click-show-picture-in-ie6/ Share on other sites More sharing options...
r-it Posted June 12, 2007 Author Share Posted June 12, 2007 after 2 sleepless nights, all i had to do was to put a # in my href, like this <a href="#" onclick="..."> because explorer is stupid, this is now solved Link to comment https://forums.phpfreaks.com/topic/55244-solved-image-only-works-after-right-click-show-picture-in-ie6/#findComment-273058 Share on other sites More sharing options...
Yesideez Posted June 12, 2007 Share Posted June 12, 2007 One problem I found when using PHP to make images was that sometimes IE would show the cached image instead of showing a new one. To get around this problem I'd fool the browser into thinking the image was a different link by appending a random number on the end, something like this: $img = '<img src="./captcha.php?'.mt_rand(1,10000).'" alt="Security code" width="130" height="35" id="captcha" />'; Link to comment https://forums.phpfreaks.com/topic/55244-solved-image-only-works-after-right-click-show-picture-in-ie6/#findComment-273062 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.