473,321 Members | 1,778 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

BACK problem

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
3 2040
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: lawrence | last post by:
I've been bad about documentation so far but I'm going to try to be better. I've mostly worked alone so I'm the only one, so far, who's suffered from my bad habits. But I'd like other programmers...
19
by: jameso321 | last post by:
Hi, We run an MS Access 2000 DB with about 15 users. It is on a Win 2000 Server (SP4) machine and runs through Citrix Metaframe Presentation Server 3.0. --------------------------
1
by: Peter D. Dunlap | last post by:
Hello, I realize that this may not be the best place to ask this question, through the application is asp.net. I also realize that questions about disabling the back button are generally met...
5
by: Brad | last post by:
I created a base page class which sets a response filter and the filter injects additional html into the response output stream. The filter works fine and everything works as expected except for...
3
by: Andre | last post by:
Hi, I have a page with 3 options, when a user select one, he's redirected to a page with several option (checkbox) each of them with autopostback set to true. My problem is : If the user...
1
by: Johan Nedin | last post by:
Hello! I am having a problem with the @OutputCache page directive and Web browser Back Buttons. Problem: After setting <%@ OutputCache Location="None" %> on my pages I get the "Warning!...
2
by: Tammy | last post by:
Hello - I have read many threads regarding back-end security and have found them all useful. I have a couple of (what seem to be basic) questions: I have a secured front-end and back-end...
4
by: Joseph Geretz | last post by:
We use a Soap Header to pass a token class (m_Token) back and forth with authenticated session information. Given the following implementation for our Logout method, I vastly prefer to simply code...
3
by: evenlater | last post by:
Using Access 2007, I've found that combo box back colors change to transparent from normal inconsistently for no reason I can discern. Never had that problem in previous versions of Access. I do...
8
by: Harvey Schmidlapp | last post by:
I have a fairly complex form (generated by means of an ASP 3 page). The form is used to define a query against a database. After running a query, the user hits their browser's back button and goes...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.