Jump to content

Image verification code problems


sford999

Recommended Posts

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]<?php

echo '<!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]<?php

session_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 out

echo "<img src="verify.png">";

// More form html stripped out

?>[/code]

On the form processing script I have this

[code]<?php

session_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?
Link to comment
https://forums.phpfreaks.com/topic/4277-image-verification-code-problems/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.