I am creating a simple web page application and in my question are involved 2 pages and there are two scenarios.
Scenario No 1
On page1.php
I use php with MySQL to get a product's data to the page. When a user wants to proceed to page, 2 he clicks on a button.
On page2.php
there is also some info about the product, mainly pricing and shipping. For this data to be displayed I make use of the ID of the product so page2.php
is actually page2.php?id=123
. Therefore, using again PHP and MySQL I get the data I need.
Scenario No 2
On page1.php
I use php with MySQL to get a product's data to the page. The needed values for page2.php
are stored in sessions. When a user wants to proceed to page 2
, he clicks on a button.
On page2.php
now, the information about the product is shown using sessions. No need to use the database again. This time page2.php
is actually page2.php
that it is shown on the address bar.
Differences between the two scenarios
In scenario #1, a user has the option to send to a friend this www.domain.com/page2.php?id=123
and get him directly to the "checkout" page. There will be use of the database twice.
In scenario #2, if a user sends/copies the link of the address bar to a friend www.domain.com/page2.php
he will get a notice message in the form "please choose a product first". Use of sessions.
Which approach is the best way to proceed?