<?php /** * @author switch * @copyright 2015 * 处理付款细节,将订单添加到数据库 */ //require_once语句和require语句完全相同,唯一区别是PHP会检查该文件是否已经被包含过,如果是则不会再次包含。 require_once('book_sc_fns.php'); session_start(); do_html_header('Checkout'); //创建变量 $card_type = $_POST['card_type']; $card_number = $_POST['card_number']; $card_month = $_POST['card_month']; $card_year = $_POST['card_year']; $card_name = $_POST['card_name']; if(($_SESSION['cart']) && ($card_type) && ($card_number) && ($card_month) && ($card_year) &&($card_name)) { //显示没有图片,不允许更改数量的购物车 display_cart($_SESSION['cart'],false,0); display_shipping(calculate_shipping_cost()); if(process_card($_POST)) { //清空购物车 session_destroy(); //这里可以写一些关于信用卡接口调用的函数,调用银行写好的接口 echo "<p>Thank you for shopping with us. Your order has been placed.</p>"; display_button("index.php","continue-shopping","Continue Shopping"); } else { echo "<p>Could not process your card. Please contact the card issuer or try again.</p>"; display_button("purchase.php","back","Back"); } } else { echo "<p>You did not fill in all the fields,please try again.</p><hr/>"; display_button("purchase.php","back","Back"); } do_html_footer(); ?>
以上就是php实现购物车功能的前篇,代码很详细,希望对大家的学习有所帮助,之后还有下篇分享给大家,不要错过。
您可能感兴趣的文章: