Hi,
I have a simple form with radio button and a hidden field.
I want to post the info to db and do simple calculation at the same time, but it doesn't work.Code:Item: <form action="process.php" method="post"> <input name="item" type="radio" value="DVD"> DVD <input name="item" type="radio" value="VHS">VHS Quantity: <input name="quantity" type="text"> <input name="cost" type="hidden"> </form>
In process.php, I have:
The item[DVD or VHS] and quantity are posted OK to db, but the cost is 0. What's wrong?Code:<?php $item = $_POST['item']; $quantity =$_POST['quantity']; $cost = $_POST['cost']; if($item=="DVD") $cost=$quantity*2; else $cost=$quantity*1; mysql_query ("INSERT INTO list (item,quantity,cost) VALUES('$item','$quantity','$cost')",$connection); ?>
Thanks



Reply With Quote

Bookmarks