BrandonE97 Posted May 9, 2007 Share Posted May 9, 2007 Im making my first captcha script and what I found on the net works great but Im not able to output any html after the image is created. Here is what I have so far: <?php $md5 = md5(microtime() * mktime()); $string = substr($md5,0,5); $key = md5($string); setcookie("BrandonE97_Captcha", $key, 0); $captcha = imagecreatefrompng("./captcha.png"); $text = imagecolorallocate($captcha, 0, 153, 255); $line = imagecolorallocate($captcha,255,255,255); $x1 = rand(0,80); $y1 = rand(0,10); $x2 = rand(0,80); $y2 = rand(40,30); imageline($captcha,$x1,$y1,$x2,$y2,$line); $x1 = rand(0,80); $y1 = rand(0,10); $x2 = rand(0,80); $y2 = rand(40,30); imageline($captcha,$x1,$y1,$x2,$y2,$line); $x1 = rand(0,80); $y1 = rand(0,10); $x2 = rand(0,80); $y2 = rand(40,30); imageline($captcha,$x1,$y1,$x2,$y2,$line); imagestring($captcha, 5, 20, 10, $string, $text); header("Content-type: image/png"); imagepng($captcha); header("Content-Type: text/html"); // I added this thinking it may fix my problem but I still have no output. ?> <br /> <?php if ($_COOKIE['BrandonE97_Captcha'] == $key) { // all of this is for testing echo('hi'); } else { echo('no'); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/50581-changing-headers/ Share on other sites More sharing options...
per1os Posted May 9, 2007 Share Posted May 9, 2007 You are contradicting yourself. Most captcha scripts have a single file that generates the image because of the fact you can only output one header. You may be able to use output buffering to solve this, but as far as this is concerned you just need to reference this script via the image html code. <img src="yourCaptchaScript.php" /> Quote Link to comment https://forums.phpfreaks.com/topic/50581-changing-headers/#findComment-249056 Share on other sites More sharing options...
BrandonE97 Posted May 9, 2007 Author Share Posted May 9, 2007 Okay, wasnt sure on how to do that. Thanks very much. Quote Link to comment https://forums.phpfreaks.com/topic/50581-changing-headers/#findComment-249060 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.