Ive been playing around with a simple shopping cart and sessions. I want the script to echo the amount everytime someone hits the add to cart button. So I would like the script to keep adding the amounts even for when someone repeatedly hits the button. heres my script:
In the head i have:
<script>
<?
session_start();
$toupeeqty = $_POST['toupeeqty'];
$_SESSION['toupee'] = "$toupeeqty";
if(isset($_SESSION['toupee']))
$_SESSION['toupee'] = $_SESSION['toupee'] + $toupeeqty;
else
$_SESSION['toupee'] = $toupee;
?>
and heres what i have in the body:
<img src = "toupee.jpg" /><br/>
<form action = "question1.php" method = "post">
How many toupees would you like?<br/>
<input type = "text" name = "toupeeqty" value = "1"/>
<input type = "submit" name = "submit" value = "Add to cart" />
</form><br/><br/>
</br><br/>
Click image to preview the Wild Wacky Action Bike!<br/><br/>
<img src = "wacky.jpg" onclick="previewbike();"/><br/>
<br/><br/>
<form action = "question1.php" method = "post">
How many wild wacky action bikes would you like?<br/>
<input type = "text" name = "wackybikeqty" value = "1"/>
<input type = "submit" name = "submit" value = "Add to cart" />
</form><br/><br/>
<?
echo $_SESSION['toupee'];
?>
Everytime i enter an amount the script just doubles the value. how do i get the script to keep adding amounts entered? thanks in advance