• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 241
  • Last Modified:

Why does my page need to be refreshed to show the shopping cart update?

Hi, I have a function that returns the correct update:

function updateCart() {
      if((isset($_POST['update'])) && (isset($_POST['qty'])) && (isset($_POST['item']))) {
            $item = trim(mysql_clean_strings($_POST['item']));
            $qty = trim(mysql_clean_strings($_POST['qty']));
            $cart = $_SESSION['cart'];
            $_SESSION['cart'][$item] = $qty;
            var_dump($qty);
            return $qty;
      }
}

but it doesn't show the update till the next time (either enter a new quantity or click refresh).  How can I make it show the changes on the first click (submit) ?

You will need to add something first:

http://auroriella.com/bracelet.php?item=b3
0
FairyBusiness
Asked:
FairyBusiness
1 Solution
 
hieloCommented:
You need to do the update at the very start of the page. That way by the time you begin sending the "main" content for the page, $_SESSION will already reflect the updates.
0
 
FairyBusinessAuthor Commented:
Thanks!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now