Sincve you are not using e-commerce there is little need for security.
I think seesions are fairly secure and they allow you to store variables without writing to the database. Then you retrieve the variables with $_POST.
global $total_price;
global $items;
if(!$items) $items = "0";
if(!$total_price) $total_price = "0.00";
echo "Total Items = $items";
Then the code to calculate price.
You could prbrably simply this by passing a simple array.
function calculate_price($cart)
{
// sum total price for all items in shopping cart
$price = 0.0;
if(is_array($cart))
{
$conn = db_connect();
foreach($cart as $isbn => $qty)
{
$query = "select price from books where isbn='$isbn'";
$result = mysql_query($query);
if ($result)
{
$item_price = mysql_result($result, 0, "price");
$price +=$item_price*$qty;
}
}
}
return $price;
}
P.S. I could not find the page to create my own computer send me an exact link and I will check it out.