images + sessions

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
maverickman55
Forum Newbie
Posts: 15
Joined: Sat Dec 14, 2002 10:22 pm

images + sessions

Post 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>
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post 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>
maverickman55
Forum Newbie
Posts: 15
Joined: Sat Dec 14, 2002 10:22 pm

Post 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?
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post 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?
maverickman55
Forum Newbie
Posts: 15
Joined: Sat Dec 14, 2002 10:22 pm

Post 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
Post Reply