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

Technical Lead
Thomson Reuters (Markets) LLC
US-NY-New York

Justtechjobs.com Post A Job | Post A Resume
Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?


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, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business

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

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