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?

  • can we have a link to the interface?
    – colmcq
    Commented Aug 19, 2011 at 8:41

3 Answers 3


It depends.

From a pure usability perspective, it's better to be able to provide a direct link to the product. But from a business perspective, there's a reason why the dairy is at the end of the store. You want the user to see the variety of available products, the current sales and special offers. Unless you provide these on the product page, you'll probably want your user to go through a preliminary step where you can show off your goods.

But there's another point here - if you're planning on Scenario #1 in order to let the user use the URL, then you absolutely shouldn't rely on him interacting with the URL directly in the address bar. You need to provide explicit buttons, like "send to a friend". This serves both as a call to action, encouraging him to do something he may not have intended in the first place, and as a way to make the action easier - because sending direct URLs is an advanced action, and the majority of your visitors won't use it.

  • I totally agree with you, I must be misunderstood. I will never provide a "copy the adress bar and paste it to a friend" that's for sure.
    – EnexoOnoma
    Commented Aug 19, 2011 at 11:47

The first way is the better way for the reason you stated: the user can bookmark and share the link, it will also 100% work if his browser crashes and he restores the tab.

There should also be no downside to that database hit on page2.php anyway, and in a session, the data won't get updated in the unlikely event that the details change if the user goes from page1 to page2.

One question you should ask yourself is why are you making the user click twice to find out shipping information? If you supply some more context we could give you better advice.

  • Excuse me for misunderstanding, on page2 there will be like a confirmation/checkout fill like those on groupon. All details will be provided as well on page1.php
    – EnexoOnoma
    Commented Aug 19, 2011 at 11:38

Both scenarios can be mixed.

On page2.php, simply check if the session exists for the user. If not, check the querystring to see if a product ID was provided. If so, set up the session with a call to the database. Now you can continue as if the original user was ordering the product.

When no session is present and the querystring doesn't contain the product, make sure to either redirect the user to a relevant location (perhaps page1.php), show a message on page2.php telling the user what went wrong, or redirect to page1.php and show the message there (I think the latter is the prefered one).

As for the don't letting the user work with the url directly as suggested in another answer. I agree, allow the user to send the URL through a button click.

  • Saying "do not allow the user to work with the url" you mean do not tell to the user "copy and paste the address bar to a friend" ?
    – EnexoOnoma
    Commented Aug 19, 2011 at 11:45
  • Exactly. I was refering to another answer to the question where this was mentioned. I fixed mine so it should be more clear.
    – Thorsal
    Commented Aug 19, 2011 at 12:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.