PHP and MySQL Web Development - P115: PHP and MySQL Web Development teaches the reader to develop dynamic, secure, commercial Web sites. Using the same accessible, popular teaching style of the first edition, this best-selling book has been updated to reflect the rapidly changing landscape of MySQL and PHP. | 542 Chapter 25 Building a Shopping Cart Implementing Payment When the user clicks the Purchase button we will process her payment details using the can see the results of a successful payment in Figure . The code for can be found in Listing . Listing The Script Processes the Customer s Payment and Tells Her the Result php include The shopping cart needs sessions so start one session_start do_html_header Checkout card_type HTTP_POST_VARS card_type card_number HTTP_POST_VARS card_number card_month HTTP_POST_VARS card_month card_year HTTP_POST_VARS card_year card_name HTTP_POST_VARS card_name if HTTP_SESSION_VARS cart card_type card_number card_month card_year card_name display cart not allowing changes and without pictures display_cart HTTP_SESSION_VARS cart false 0 display_shipping calculate_shipping_cost if process_card HTTP_POST_VARS empty shopping cart session_destroy echo Thankyou for shopping with us. Your order has been placed. display_button continue-shopping Continue Shopping else echo Could not process your card. echo Please contact the card issuer or try again. display_button back Back else echo You did not fill in all the fields please try again. hr display_button back Back Implementing Payment 543 Listing Continued do_html_footer The crux of this script is these lines if process_card HTTP_POST_VARS empty shopping cart session_destroy echo Thankyou for shopping with us. Your order has been placed. display_button continue-shopping Continue Shopping We process the user s card and if all is successful destroy her session. The card processing function as we have written it simply returns true. If you were actually implementing it you would need to perform some validation checking that the expiry date was valid and the card number well-formed and then process the actual payment. Figure This transaction was .