I have a page where you view what is in your cart (a work in progress obviously) and there is a button to clear your cart, and it works, but moving to another page in the site, whether by clicking a link or typing in the address bar, runs the form action. It also does it on the product page to add to the cart. How do I stop this happening so the action only runs when the button is pressed?
<div id="">
<?php echo "You have " . $_SESSION['cartItems'];
if($_SESSION['cartItems'] == 1){
echo " item";
} else {
echo " items";
}
echo " in your cart amounting to $" . $_SESSION['cartPrice'];?>
<form action="<?php session_destroy();?>"><input type="submit" value="Clear Cart"></form>
</div>