storing urls

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

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

storing urls

Post by maverickman55 »

hey all, on my ecard script, a person first chooses an image, the image is then stored as $image in a session. on the card page, the image is shown and the user enters all there data. when they go to view their card, the unique id retrieves there information. how would i store the image url and then retrieve it when the person views there card? thanks in advance :D
Beans
Forum Commoner
Posts: 49
Joined: Mon Dec 23, 2002 3:06 am
Location: Manila, Philippines
Contact:

Post by Beans »

Have you considered the normal way of how eCard sites operate regarding this? Why do you need to store the image URL while it is being viewed (and not yet sent)? Instead of using a cookie, it is better to just pass the info along using POST.
maverickman55
Forum Newbie
Posts: 15
Joined: Sat Dec 14, 2002 10:22 pm

Post by maverickman55 »

how do norm ecard sites do this? i'm trying to do this without looking at ecard site code. all i'm wanting to do is somehow store in the row with the unique id for each card, something that tells the page which image the person selected, so when they view their card, it shows the image. if i'm storing the image as $image, and then i pass that along to the table through POST, wouldn't that store the actual image in the db?
Beans
Forum Commoner
Posts: 49
Joined: Mon Dec 23, 2002 3:06 am
Location: Manila, Philippines
Contact:

Post by Beans »

No. You don't actually have to look at eCard codes... here's how it works:

1. User selects a card
2. User submits his/her choice
3. Image ID (or URL) gets passed to a php file
4. User enters values for emails, names, etc. (they may either see the image selected or not)
5. User has the option to either preview the card or send it.
6. IF PREVIEW: pass all values to the preview script (NO DB insertion at this point yet)
7. IF SEND: insert values to DB including the generated key for getting the card.
8. If saving is successful, send the message to the recipient/s
maverickman55
Forum Newbie
Posts: 15
Joined: Sat Dec 14, 2002 10:22 pm

Post by maverickman55 »

ok now here's my question. i have a index page where there is a bunch of images that are links, when the user clicks on the image, it is stored as $image and then echoed. if i wanted to pass the url to a db...how would i do that? if i wanted to store the url...would i create a new variable on the card creation page such as: $url="images/$image" and then echo that possibly? i'm a newb btw, but have learned a lot because of this project
Beans
Forum Commoner
Posts: 49
Joined: Mon Dec 23, 2002 3:06 am
Location: Manila, Philippines
Contact:

Post by Beans »

Can you paste the code snippet of your index.php and the ecard page?

Once you clicked on the link, you have to pass $image as a parameter to the ecard page.. for example.. image1 has a link to ecard.php. In order to tell ecard.php that the image they selected was image1, you have to make the link in index.php such that it will look like:

Code: Select all

<a href="ecard.php?image=image1">Image 1</a>
When it is clicked, the variable named image would then be passed to ecard.php with value of "image1". Thus, to show this, just:

Code: Select all

echo $image;
To show the image corresponding to the image name, do something like:

Code: Select all

print "<img src="image/$image alt=$image">
maverickman55
Forum Newbie
Posts: 15
Joined: Sat Dec 14, 2002 10:22 pm

Post by maverickman55 »

thats exactly what i've done. my question is how would i grab the url of the image and store it in the db? or should i go about this some other way? all i need to do is somehow tell the row what image was selected...so when the user goes to card.php?id=X, the image from table X is echoed. do you get what i mean?
Post Reply