Script execution after clicking a link

Asked

Viewed 47 times

0

I am learning PHP and my challenge is to make a shopping cart using SESSION.

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

It is possible?

1 answer

0

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

After making your logical add the product in the section just redirect

header('Location: '.$_SERVER['HTTP_REFERER']);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.