I’m creating a basic shopping cart script , located at php/cart.php, with a GET for “action” and a switch for it that either adds or removes a variable from the $_SESSION, or unsets it altogether. What’s the easiest way to create a button that, when clicked, uses this script to manage the session items?
Also would it be better to try and refresh the div containing info from the session, or just refresh the whole page?
this answer might not be appropriate, as you did not list ajax or jQuery in your question, but I would do it in the following way:
First I would make a button with a call to a function:
Then in the javascript, aided by jQuery:
Then on the php page I would just:
This is a very simple example. It is just to illustrate the basics of a simple technique. Hope it helps.