Specifications

session_start();
do_html_header(“Checkout”);
// if filled out
if($from==’process’||$cart&&$name&&$address&&$city&&$zip&&$country)
{
// able to insert into database
if($from!=’process’)
{
if(!insert_order($HTTP_POST_VARS))
{
echo “Could not store data, please try again.”;
display_button(“checkout.php”, “back”, “Back”);
do_html_footer();
exit;
}
}
//display cart, not allowing changes and without pictures
display_cart($cart, false, 0);
display_shipping(calculate_shipping_cost());
//get credit card details
display_card_form($HTTP_POST_VARS);
display_button(“show_cart.php”, “continue-shopping”, “Continue Shopping”);
}
else
{
echo “You did not fill in all the fields, please try again.<hr>”;
echo “<form action = ‘checkout.php’ method = post>”;
// pass the data this page received back so the user won’t have to re-enter
foreach($HTTP_POST_VARS as $name => $value)
echo “<input type = hidden name = $name value = ‘$value’>\n”;
display_form_button(“back”, “Back”);
echo “</form>”;
}
do_html_footer();
?>
Building a Shopping Cart
C
HAPTER 25
25
B
UILDING A
SHOPPING CART
569
LISTING 25.14 Continued
31 7842 CH25 3/6/01 3:39 PM Page 569