Specifications

$query = “delete from order_items where
orderid = $orderid and isbn = ‘$isbn’”;
$result = mysql_query($query);
$query = “insert into order_items values
(‘$orderid’, ‘$isbn’, “.$detail[“price”].”, $quantity)”;
$result = mysql_query($query);
if(!$result)
return false;
}
return $orderid;
}
?>
This function is rather long because we need to insert the customers details, the order details,
and the details of each book they want to buy.
We then work out the shipping costs to the customers address and tell them how much it will
be with the following line of code:
display_shipping(calculate_shipping_cost());
The code we are using here for calculate_shipping_cost() always returns $20. When you
actually set up a shopping site, you will have to choose a delivery method, find out how much
it costs for different destinations, and calculate costs accordingly.
We then display a form for the user to fill in her credit card details using the
display_card_form() function from the output_fns.php library.
Implementing Payment
When the user clicks the Purchase button, we will process her payment details using the
process.php script. You can see the results of a successful payment in Figure 25.10.
Building Practical PHP and MySQL Projects
P
ART V
572
LISTING 25.15 Continued
31 7842 CH25 3/6/01 3:39 PM Page 572