While developing the code I was displaying the template graphic (Line 18 of the code) in which case the redirection failed. But by, commenting out that line, redirection worked.
Can you explain that behaviour?
Bob
<?php session_start();
header('Content-Type: image/png');
$serial = "ABC123X"; // normally passed as a session variable
$imgname = 'blankorder.png';
$img = @imagecreatefrompng($imgname); // open image file
if(!$img) // failed to open
{
$img = imagecreatetruecolor(300, 30);
$bak = imagecolorallocate($img, 255, 255, 255);
$txt = imagecolorallocate($img, 255, 0, 0);
imagefilledrectangle($img, 0, 0, 300, 30, $bak);
imagestring($img, 5, 0, 0, 'Error loading ' . $imgname, $txt); //error message
imagepng($img);
die();
}
else
{
// imagepng($img); // Puts blank form on screen but, if implemented, the redirection doesn't work
$textcolour = imagecolorallocate($img, 0, 0, 0);
// Font converted from ttf using http://www.wedwick.com/wftopf.exe
$font = imageloadfont('Arial24.gdf');
imagestring($img, $font, 535, 312, $serial, $textcolour); // insert serial no. in required position
imagepng($img,'overlaid.png'); // save overlaid image as a file
imagedestroy($img);
// header('Content-Type: text/html; charset=iso-8859-1'); // appears to be redundant
header('refresh: 0; url=stamped.html'); // redirect to specified page
}
?>
header('Content-Type: image/png');
$serial = "ABC123X"; // normally passed as a session variable
$imgname = 'blankorder.png';
$img = @imagecreatefrompng($imgname); // open image file
if(!$img) // failed to open
{
$img = imagecreatetruecolor(300, 30);
$bak = imagecolorallocate($img, 255, 255, 255);
$txt = imagecolorallocate($img, 255, 0, 0);
imagefilledrectangle($img, 0, 0, 300, 30, $bak);
imagestring($img, 5, 0, 0, 'Error loading ' . $imgname, $txt); //error message
imagepng($img);
die();
}
else
{
// imagepng($img); // Puts blank form on screen but, if implemented, the redirection doesn't work
$textcolour = imagecolorallocate($img, 0, 0, 0);
// Font converted from ttf using http://www.wedwick.com/wftopf.exe
$font = imageloadfont('Arial24.gdf');
imagestring($img, $font, 535, 312, $serial, $textcolour); // insert serial no. in required position
imagepng($img,'overlaid.png'); // save overlaid image as a file
imagedestroy($img);
// header('Content-Type: text/html; charset=iso-8859-1'); // appears to be redundant
header('refresh: 0; url=stamped.html'); // redirect to specified page
}
?>
