Jump to content

brash21

New Members
  • Posts

    1
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

brash21's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. 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
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.