spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / programming / carts / chap7 / 2 To page 1current pageTo page 3To page 4To page 5To page 6To page 7To page 8
[previous] [next]

Usable Shopping Carts, Chapter 7: CC Validation and Verification

Data Center Architect
The Computer Merchant, Ltd
US-MA-chelsea

Justtechjobs.com Post A Job | Post A Resume
Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs


This next part should look familiar as it's almost identical to the first portion of the code we used in Step 2 to include the error-checking routines for validation:

<?php

  $err_msg = "<p class=\"error\">There were problems 

                                   with the following fields:</p>\n<p>";

  require_once "../includes/validate.inc";

  $valid = TRUE;

  if( isset($HTTP_POST_VARS["$cc_submit"]) )

  {

    $cc_submit = $HTTP_POST_VARS["$cc_submit"];

    $valid = validate();

  }

  if( $err_msg != 

  "<p class=\"error\">There were problems with the following fields:</p>\n<p>" )

  {

    echo "<table border=\"2\" bordercolor=\"#CC0033\" 

                 bgcolor=\"#FFFEE\" cellpadding=\"2\">\n<tr><td>";

    echo $err_msg;

    echo "</td></tr>\n</table>\n";

  }

  if( isset($cc_submit) && $valid )

  {

Once the form is validated, we're ready to process the order. First, we retrieve some values that were passed from the previous page via POST:

    $ship_type = $HTTP_POST_VARS["ship_type"];

    $order_total = $HTTP_POST_VARS["order_total"];

We're still using the variable $s_id to hold the value of the session ID, but now we'll maintain it between page loads by storing it as the value of a hidden form field and retrieving it from $HTTP_POST_VARS:

    $s_id = $HTTP_POST_VARS["s_id"];

Then we create a new record in the orders table. It's assumed that only records relating to paid orders are stored here:

    $o_query = "INSERT INTO orders 

               (session_id,shipping_type_id,order_total,order_datetime) ";

    $o_query .= "VALUES ('$s_id','$ship_type','$order_total',NOW())";

    $o_result = mysql_query($o_query)

      or die("<p>There was a problem in processing your order. Please contact 

      us by email or phone for further assistance. Please be ready to supply 

      your reference code, which is <b>$s_id</b>, so that we can 

      retrieve your ordering information.</p>");

home / programming / carts / chap7 / 2 To page 1current pageTo page 3To page 4To page 5To page 6To page 7To page 8
[previous] [next]

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint

Created: December 26, 2002
Revised: December 26, 2002

URL: http://webreference.com/programming/carts/chap7/2/2.html