Running the script after clicking a link

0

I'm learning PHP and my challenge is to make a Shopping Cart using SESSION.

In my logic, I am trying to run a array_push , after clicking the "insert product in cart" link, from the product page and thus "fill" the array created through SESSION and which is on the "Cart" page, at the same time that I'm directed to this page.

Is it possible?

    
asked by anonymous 21.10.2015 / 18:22

1 answer

0

You can make a redirect to the reference page using $_SERVER['HTTP_REFERER']

After you make your logic of adding the product in session just redirect

header('Location: '.$_SERVER['HTTP_REFERER']);
    
21.10.2015 / 18:27