Eggzorcist Posted September 16, 2008 Share Posted September 16, 2008 I have one major issue with my captcha, It's doing everything I want it to but one thing. I thinks its alone on the page and makes my register.php a png image and outputting nothing else but itself. heres my code: <?php function create_captcha($length){ //Creates md5 hash $hash = md5(rand(0, 9999)); //creates a code with $length $code = substr($hash, 15, $length); //stores the code into a session $_SESSION['captcha'] = $code; //image size $width = 150; $height = 50; //creates the image $image = imagecreate($width, $height); //creates background and text colours $background = imagecolorallocate($image, 0, 0, 0); $text = imagecolorallocate($image, 255, 255, 255); //creates the image imagefill($image, 0, 0, $background); //Specifies font and text imagettftext($image, 42, 5, 15, 55, $text, "captcha.ttf", $code); //Tells the browser what kind of image is being outputted. header("Content-Type: image/png"); //creates the image imagepng($image); //frees up resources imagedestroy($image); } ?> thanks Link to comment https://forums.phpfreaks.com/topic/124475-solved-issues-with-captcha/ Share on other sites More sharing options...
JasonLewis Posted September 16, 2008 Share Posted September 16, 2008 Instead of making it a function, just make it a standalone file. Then you need to call the filename as the image src. <img src="dir/to/captcha.php" alt="" /> Link to comment https://forums.phpfreaks.com/topic/124475-solved-issues-with-captcha/#findComment-642800 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.