A
Anonymous
Guest
I have been having several issues with creating a dynamic image using the <img src="image.php"> method. I would greatly appreciate any help I can get on these things.
Here's the basics of how the site works to explain the context for these problems:
On the main page, you can click three links to choose three different images. Each link opens a pop-up window, with a selection of possible images. The popup checks via session variables if an image has already been chosen, and displays it if so. When a different image is chosen, it reloads the main page with a get command in the url referencing the image (an if statement on the main page checks for this and stores it in the correct session variable). As a result, the main page and the three pop-ups all have session_start() and deal with session variables.
When two or more images have been chosen, the main page is supposed to combine them, and then show the result. Obviously I can't do this right on the page because of the headers already sent issue, I tried making a class which had a display() function, which didn't address the headers thing, and finally settled on a reference to a php page through the image tag as the only way to get it done without messing around with output buffering (since I don't know much about it and wasn't able to find much in the way of explanation online).
Hokay, so. I reference the image creation page like so from the main page:
I cannot use session variables with image.php without totally deleting all the session variables already stored by the main page. I don't understand why this is, but it seems that when I have session_start() at the top of image.php, it creates a totally new session with blank (or missing) variables. Why is this? Is it possible to use session variables on this page without deleting the session inadvertantly?
Before anyone asks, I also tried this code, which has the same problem:
Is it just impossible to use sessions with a page referenced the way this one is?
The session problem is my main one, but something that might be related is that the image.php file can not find global variables declared on the main page. define("SECURE", true) on the main page, followed by if (!defined("SECURE")) { die(); } in image.php results in the file dying.
My quick fix was to put the image variables in the URL call to image.php (i.e. src="image.php?image=whatever&image2=whichever"), but this is very confining, particularly since I want to be able to add text to the images, which could run into problems as far as URL length goes.
I would greatly appreciate any help that you folks can give me, since these issues with images have been driving me up the wall. I've been unable to find any good fixes in the php manual, and none of the things that I tested worked out. I have only recently started programming PHP, so if there are any resources that I don't know about, I would love a link.
Thank you for your help!
Here's the basics of how the site works to explain the context for these problems:
On the main page, you can click three links to choose three different images. Each link opens a pop-up window, with a selection of possible images. The popup checks via session variables if an image has already been chosen, and displays it if so. When a different image is chosen, it reloads the main page with a get command in the url referencing the image (an if statement on the main page checks for this and stores it in the correct session variable). As a result, the main page and the three pop-ups all have session_start() and deal with session variables.
When two or more images have been chosen, the main page is supposed to combine them, and then show the result. Obviously I can't do this right on the page because of the headers already sent issue, I tried making a class which had a display() function, which didn't address the headers thing, and finally settled on a reference to a php page through the image tag as the only way to get it done without messing around with output buffering (since I don't know much about it and wasn't able to find much in the way of explanation online).
Hokay, so. I reference the image creation page like so from the main page:
Code:
<img src="image.php" alt="Whatever">
I cannot use session variables with image.php without totally deleting all the session variables already stored by the main page. I don't understand why this is, but it seems that when I have session_start() at the top of image.php, it creates a totally new session with blank (or missing) variables. Why is this? Is it possible to use session variables on this page without deleting the session inadvertantly?
Before anyone asks, I also tried this code, which has the same problem:
Code:
if (!session_id()) {
session_start();
}
Is it just impossible to use sessions with a page referenced the way this one is?
The session problem is my main one, but something that might be related is that the image.php file can not find global variables declared on the main page. define("SECURE", true) on the main page, followed by if (!defined("SECURE")) { die(); } in image.php results in the file dying.
My quick fix was to put the image variables in the URL call to image.php (i.e. src="image.php?image=whatever&image2=whichever"), but this is very confining, particularly since I want to be able to add text to the images, which could run into problems as far as URL length goes.
I would greatly appreciate any help that you folks can give me, since these issues with images have been driving me up the wall. I've been unable to find any good fixes in the php manual, and none of the things that I tested worked out. I have only recently started programming PHP, so if there are any resources that I don't know about, I would love a link.
Thank you for your help!