Page 1 of 1

images + sessions

Posted: Sat Dec 14, 2002 10:50 pm
by maverickman55
hey guys, i'm making an ecard system, and i need one page where it displays a bunch of images, and then when the user clicks on the image they want...it takes them to the "card" page, and then the image is "echoed". i know you can do that with sessions, but i can't get my code to work. could someone talk a look and try to help? thanks

Image Selection Page

Code: Select all

<html>
<body>
<a href="viewimage.php?image=winter.jpg"><img src="images/winter.jpg"></a>
</body>
</html>
Output Page

Code: Select all

<?
session_start();
session_register("image");
?>
<html>
<body>
<img src="<?echo $image;?>">
</body>
</html>

Posted: Sun Dec 15, 2002 3:25 pm
by Gen-ik
You don't really need to use a session for this do you?

It would be easier to do this..


IMAGE SELECTION (no changes here)

Code: Select all

<html> 
<body> 
<a href="viewimage.php?image=winter.jpg"><img src="images/winter.jpg"></a> 
</body> 
</html>

OUTPUT (spot the changes)

Code: Select all

<html> 
<body> 
<img src="<?php echo ("images/".$image); ?>"> 
</body> 
</html>

Posted: Sun Dec 15, 2002 4:41 pm
by maverickman55
i need to somehow store the image, and then retrieve it when the user follows the link. do u think i should store the image in a db? i don't really want each image being stored EVERY TIME someone chooses it. now could i use sessions?

Posted: Sun Dec 15, 2002 6:53 pm
by Gen-ik
Just out of curiosity why do you want to store the image?

Couldn't you just store the paths to the image(s) in an array?

Posted: Sun Dec 15, 2002 9:37 pm
by maverickman55
in your opinion, how should i store the information needed, whether the image or an array, so that when the person follows the link to view their card, it shows the image along with the rest of the text? how would go about doing this with an array? thanks