|
Posted by Jerry Stuckle on 05/13/07 15:55
Martien van Wanrooij wrote:
> In a simple webshop application I am trying to check that the "shopping
> cart" only should be "filled" when you choose an article in
> "meerinfo.php" and click on a link to "winkelwagen.php". It works fine
> in that sense that when I would enter in the browser
> "www.mysite.php/winkelwagen?id=5"it will be ignored.
> However when I go from meerinfo.php to winkelwagen.php , the article is
> added again and again to the shopping cart when I click on the refresh
> button in Internet Explorer. Is there a way to avoid that?
>
> This is the code in winkelwagen.php
>
> if(!isset($_SESSION['artikelen'])) //initiate the array when the first
> article is added to the shopping cart
> {
> $_SESSION['artikelen'] = array();
> }
> $waarvandaan = $_SERVER['HTTP_REFERER'];
> if (strstr($waarvandaan, "meerinfo.php"))
> {
> $id = $_GET['id'];
> $_SESSION['artikelen'][] = $id;
> }
>
> Thanks for any help (or suggestions for articles that discuss this topic)
>
> Martien
Martien,
It's doing exactly what you told it to do. Every time you hit refresh
on your browser, it's exactly the same as clicking the "ad" button on
the previous page.
Rather - when you click to add an item on the first page, make it go to
an intermediate script. All that script does is add the item to the
shopping cart, then redirect (using the 'header' function) to the third
page (which displays the cart).
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Navigation:
[Reply to this message]
|