Fed up with these complicated, umpteen file freeware things that don't work so am trying to write my own simple shopping cart in PHP. I am far from expert in this language. Basic code on a single product page is:
<?php
if(isset($_POST['add']))
{
blah, blah - add cart item to database
}
?>
blah, blah HTML
<form name="checkout" method="post" action="" action="">
<button type="submit" name="add" value="add"/>Add to cart</button>
blah, blah more HTML
All works great but thought it was too easy. Found problem with self calls in that the browser history gets longer and longer, so if user adds to cart twice he has to click back three times to return to the main page. Can't delete history in PHP so is there a better way of structuring things? Or do I have to resort to cookies?
Much ta.
<?php
if(isset($_POST['add']))
{
blah, blah - add cart item to database
}
?>
blah, blah HTML
<form name="checkout" method="post" action="" action="">
<button type="submit" name="add" value="add"/>Add to cart</button>
blah, blah more HTML
All works great but thought it was too easy. Found problem with self calls in that the browser history gets longer and longer, so if user adds to cart twice he has to click back three times to return to the main page. Can't delete history in PHP so is there a better way of structuring things? Or do I have to resort to cookies?
Much ta.
Comment