sford999 Posted March 7, 2006 Share Posted March 7, 2006 I`m having some intermittent errors with an image verification I`m using.It sometimes displays:[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]The image “http://www.domain.com/page.php” cannot be displayed, because it contains errors.[/quote]But if I refresh the page it works fine.In the server error log its saying:[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--][06-Mar-2006 15:12:31] PHP Warning: Cannot modify header information - headers already sent by (output started at /home/carpfish/public_html/glossary/header.inc:38) in /home/carpfish/public_html/glossary/add.php on line 13[/quote]Yet this is what header.inc contains[code]<?phpecho '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head><title>Carp Fishing UK</title><meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /><style type="text/css">@import url( "css/css.css" );</style></head><body><br /><table width="95%" border="0" cellspacing="0" cellpadding="0" align="center" class="logoborder"> <tr> <td><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td id="logostrip"><div align="center"><a href="/?index"><img src="images/logo.jpg" /></a></div></td> </tr> <tr> <td class="divider"> </td> </tr> </table> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="20%" valign="top">'; ?>[/code]Below is the code I`m using.[code]<?phpsession_start();$new_string;session_register('new_string');include ('header.inc');include ('menu.inc');Header("Content-Type: image/png");$im = ImageCreate(200, 40); $txtcol = ImageColorAllocate($im, 249, 246, 73);$bgdcol = ImageColorAllocate($im, 0, 0, 220);srand((double)microtime()*1000000);$string = md5(rand(0,9999));$new_string = substr($string, 12, 8); ImageFill($im, 0, 0, $bgdcol); ImageString($im, 15, 60, 10, $new_string, $txtcol); ImagePNG($im, "verify.png");ImageDestroy($im);// Snip un-needed form html outecho "<img src="verify.png">";// More form html stripped out?>[/code]On the form processing script I have this[code]<?phpsession_start();$random = trim($random);if ($new_string == $random){//--------------------------// Form PHP stripped out//--------------------------}else{echo "Wrong image code entered, please go back and try again.";}?>[/code]Can anyone see why it would intermittedly show the error? Quote Link to comment https://forums.phpfreaks.com/topic/4277-image-verification-code-problems/ Share on other sites More sharing options...
jordie Posted March 7, 2006 Share Posted March 7, 2006 Remove this line, its confusing the browser. You only need that if you want the php file to be treated as an image file, where in your case you don't cause you are outputting html and saving the img data as verify.png.[code]Header("Content-Type: image/png");[/code] Quote Link to comment https://forums.phpfreaks.com/topic/4277-image-verification-code-problems/#findComment-14912 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.