By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,574 Members | 1,201 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,574 IT Pros & Developers. It's quick & easy.

Pass data to another page?

P: 7
I need to pass data from one web page to another.

For example I have 10 products, when the user clicks the price of the product I need to load a new page which can display data from the first page such as description, price, quantity etc.

not sure if i need to do this in PHP or if it can be done in HTML?

Any help appreciated.

thanks
May 13 '09 #1
Share this Question
Share on Google+
4 Replies


Markus
Expert 5K+
P: 6,050
@pqsoftware
HTML cannot do this, no. You could use Javascript to avoid using server-side programming.

However, while we are here, we may as well discuss the options.

You may have noticed complex looking URLs like so: http://site.com/?name=markus&age=18&desc=very%20sexy. This is using a route that passes information via the URL. This information can be obtained via the GET array (links at bottom). How do I get the info to the URL, you may ask? Well, if you set a form's action attribute to 'get', open submitting the form, it will create and append the data within the form to the URL. As said before, you then have access via the GET array.

Another option is the POST (links at bottom) array, this is sometimes preferable to GET as the data is not easily visible to the user; it is not passed via the URL, but by magic. This option can be achieved by setting the form's action attribute to 'post'.

There are other options such as SESSION or COOKIE that are used to pass data between pages.

Mark.
May 13 '09 #2

dlite922
Expert 100+
P: 1,584
@pqsoftware
HTML is not a programming language, but a markup language. To achieve your solution in HTML, you'd have to create a html page for each product detail and go to that page (hard code the name) from the product summary page.

to do it with PHP is very easy. You can pass it via the URL such as:

yoursite.com/productDetail.php?productID=12345

then on productDetail you can get the productID with $_GET['productID'].

From this product ID you can pull the rest of your product info from your data soruce...which I hope is a MySQL database.

Cheers,



Dan
May 13 '09 #3

dlite922
Expert 100+
P: 1,584
Ahhhg... you beat me to it. shouldn't have taken that smoke break. :)



Dan

@Markus
May 13 '09 #4

Markus
Expert 5K+
P: 6,050
It takes you 45+ minutes for a smoke? What the chuff are you smoking? ;)
May 14 '09 #5

Post your reply

Sign in to post your reply or Sign up for a free account.