コード例 #1
1
ファイル: purchase.php プロジェクト: jimlucn/cart
$address = $_POST['address'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$country = $_POST['country'];
$ship_name = $_POST['ship_name'];
$ship_address = $_POST['ship_address'];
$ship_city = $_POST['ship_city'];
$ship_state = $_POST['ship_state'];
$ship_zip = $_POST['ship_zip'];
$ship_country = $_POST['ship_country'];
do_html_header('结算');
do_html_top();
if (is_array($_SESSION['cart'])) {
    if ($name && $address && $city && $state && $zip && $country) {
        $userid = find_userid($_SESSION['valid_user']);
        if ($order_info = insert_order($_POST, $userid)) {
            display_cart($_SESSION['cart'], false, 1, 1);
            display_card_form($order_info);
        } else {
            echo "订单写入数据库失败";
        }
    } else {
        echo "用户信息填写不完整";
        display_button('checkout.php', '返回');
    }
} else {
    echo "您还没有添加商品到购物车";
    display_button('index.php', '返回首页');
}
do_html_footer();
コード例 #2
0
ファイル: purchase.php プロジェクト: kmfb21/A290CGI-PHP
<?php

include 'book_sc_fns.php';
// The shopping cart needs sessions, so start one
session_start();
do_html_header("Checkout");
// create short variable names
$name = $_POST['name'];
$address = $_POST['address'];
$city = $_POST['city'];
$zip = $_POST['zip'];
$country = $_POST['country'];
// if filled out
if ($_SESSION['cart'] && $name && $address && $city && $zip && $country) {
    // able to insert into database
    if (insert_order($_POST) != false) {
        //display cart, not allowing changes and without pictures
        display_cart($_SESSION['cart'], false, 0);
        display_shipping(calculate_shipping_cost());
        //get credit card details
        display_card_form($name);
        display_button('show_cart.php', 'continue-shopping', 'Continue Shopping');
    } else {
        echo 'Could not store data, please try again.';
        display_button('checkout.php', 'back', 'Back');
    }
} else {
    echo 'You did not fill in all the fields, please try again.<hr />';
    display_button('checkout.php', 'back', 'Back');
}
do_html_footer();