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

BACK problem

P: n/a
hi,
I have a page that takes some parameters. They are used to add items to
a cart:
add_cart.php?itemid=1234&vid=9876
This takes me to the cart page (as in "View Cart" page.)
The problem I have is that if I click on the BACK button, I get another
(of the same) item added to the cart because
"add_cart.php?itemid=1234&vid=9876" is executed again. How can I avoid
this?

Thanks a lot.
Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Xerxes wrote:
I have a page that takes some parameters. They are used to add items to
a cart:
add_cart.php?itemid=1234&vid=9876
This takes me to the cart page (as in "View Cart" page.)
The problem I have is that if I click on the BACK button, I get another
(of the same) item added to the cart because
"add_cart.php?itemid=1234&vid=9876" is executed again. How can I avoid
this?

Thanks a lot.


Can't you change the method to post?

for example

<?php // add_cart.php
session_start(); // if you need it
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// deal with input data
// and redirect
header('Location: viewcart.php');
exit('Redirected <a href="viewcart.php">here</a>.');
}
// else
// show form <form method="post" ...
?>

--
USENET would be a better place if everybody read: : mail address :
http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
http://www.expita.com/nomime.html : to 10K bytes :
Jul 17 '05 #2

P: n/a
Pedro Graca wrote:
Can't you change the method to post?


Oops ... I forgot the rest of the post :)

When the user presses BACK from the viewcart.php page after the redirect
he will be presented with the form (already filled or empty depends on a
lot of things) but he will _NOT_ do a POST!

--
USENET would be a better place if everybody read: : mail address :
http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
http://www.expita.com/nomime.html : to 10K bytes :
Jul 17 '05 #3

P: n/a
Pedro Graca <he****@hotpop.com> wrote in message news:<c5*************@ID-203069.news.uni-berlin.de>...
Pedro Graca wrote:
Can't you change the method to post?


Oops ... I forgot the rest of the post :)

When the user presses BACK from the viewcart.php page after the redirect
he will be presented with the form (already filled or empty depends on a
lot of things) but he will _NOT_ do a POST!


Hi Pedro,
thanks for the reply.
Here is what I have:
a bunch of products pages (based on categories), each product on each
page, has a "Add to Cart" button. When user clicks on add to cart
button, he goes to the view cart page. When he clicks on back, I want
to go back to that particular product page, but instead I stay in the
view cart page with the quantity of the product in cart increased by
one.
This is not a "normal" shopping cart as there a re a bunch of rules
associated with these products (e.g. can't add A if B is not already
in cart, or if you add one more of A you'll have to add one B, ...)
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.