I have a php generated image:
(number.txt contains a number 1 or 2)
pic.php
<?php
// Set the content-type
header('Content-type: image/bmp');
// Create the image
$im = imagecreatetruecolor(80, 80);
$count_my_page = ("number.txt");
$hits = file($count_my_page);
if ($hits[0] == 1) {
$im = imagecreatefrompng("image1.png");
$hits[0] ++;
$fp = fopen($count_my_page , "w");
fputs($fp , "$hits[0]");
fclose($fp);
}else{
$im = imagecreatefrompng("image2.png");
$hits[0] --;
$fp = fopen($count_my_page , "w");
fputs($fp , "$hits[0]");
fclose($fp);
}
// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 1, 1, 1);
// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
?>
And I have another page
index.html
<img src="pic.php">
<img src="pic.php">
Basically, I need one of the images on the index page to be image1 and then the second image to be image2, but it must be contained within the php file because I am unable to edit index.html. Is there anyway to do this? The method I have now where it reads a file to see if it's value is 1 or 2 doesn't seem to compute each time the image is generated. I have tried
header("Cache-Control: no-cache");
header("Pragma: no-cache");
in the image code to force it not to cache but to no avail. Can anyone solve this?