Back button re-executing script?
Posted: Tue Sep 13, 2005 4:25 pm
I am no PHP expert, and I'm trying to implement a basic shopping cart. It works like this
productinfo.php ---- product info page with 'add to cart button'. This button then calls a hyperlink to the next page like so <a href='additem.php?id=<?php $id?>'>
additem.php --- this page then adds to a basket array based on the $id it receives. There is a link on this page to..
checkout.php -- this lists the current orders..
It's all working fine, but the problem I have is that if the user hits the back button from checkout.php, they arrive back at additem.php - which then re-executes, causing the item to be added to their basket again.
Is there some way I can prevent this from happening? Like some way to 'kill' the page once it's executed, and not have it run again when it is returned to with the back button? Or is it just a flaw of my process, and is there a better way to do this kind of thing?
Thanks for any help you can give me.
productinfo.php ---- product info page with 'add to cart button'. This button then calls a hyperlink to the next page like so <a href='additem.php?id=<?php $id?>'>
additem.php --- this page then adds to a basket array based on the $id it receives. There is a link on this page to..
checkout.php -- this lists the current orders..
It's all working fine, but the problem I have is that if the user hits the back button from checkout.php, they arrive back at additem.php - which then re-executes, causing the item to be added to their basket again.
Is there some way I can prevent this from happening? Like some way to 'kill' the page once it's executed, and not have it run again when it is returned to with the back button? Or is it just a flaw of my process, and is there a better way to do this kind of thing?
Thanks for any help you can give me.