spacer

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

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

Usable Shopping Carts, Chapter 7: CC Validation and Verification

Developer-Building Trading-Pricing Appl-Capital Markets C#-WPF--WCF-XML-.Net 3.5,ASP, SQL Server
WSI Nationwide, Inc.
US-NY-New York

Justtechjobs.com Post A Job | Post A Resume
Developer News
Google Going Native With Chrome
Mozilla Fixes Firefox Flaws as 3.5 Release Nears
Microsoft and Novell Still Bosom Buddies


Now we take care of the case where either the credit card information form hasn't yet been submitted, or it has been but there were one or more validation errors. This is all quite similar to what we used for the Contact and Address form earlier in the chapter. If your credit card verification service requires more information on the cardholder, you can probably copy and paste the HTML for those form fields from checkout.php into this file, perhaps prefixing the field names with "Cardholder0" (e.g. Cardholder0Address0Line01_address_required) to avoid confusion, as we've done with the Cardholder Name and Cardholder ZIP Code fields already. The information in this form should probably not be saved anywhere unless you plan to set up user accounts and obtain permission to do so from each customer.

Do not save credit card account numbers unless you do via a secure connection and the database in which you save them can't be read from the Web.

  else

  {

?>

<h2>Credit Card Information</h2>

<p>All fields are required.</p>

<script src="../scripts/validate.js"></script>

<form action="<?php echo $PHP_SELF; ?>" method="POST" 

      onsubmit="return validate(this);">

<table width="80%" cellpadding="1" cellspacing="0" border="0">

  <tr>

    <th class="cart" colspan="2">Your name as it appears on the card:</th>

  </tr>

  <tr>

    <td class="cart" colspan="2" align="center">

      <input type="text" name="Cardholder0Name_required_alphabetic" size="50"

        value="<?php report("Cardholder0Name_required_alphabetic"); ?>" />    </td>

  </tr>

  <tr>

    <td colspan="2"><hr noshade="noshade" /></td>

  </tr>

  <tr>

    <th class="cart" colspan="2">Type of card:</th>

  </tr>

Note that there's some repetitive code here where we display the credit card types and accompanying radio buttons. Since we only use this code once and there's just three card types to worry, we don't bother with doing so here, but if we were to re-use this display elsewhere on the site, or if we began accepting more types of card, we might want to consider storing the types in an array or even in another database table.

  <tr>

    <td class="cart" align="right" width="50%">Visa</td>

    <td class="cart">

      <input type="radio" name="Credit0Card0Type_required"

        value="Visa"

<?php 

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

      && 

      $HTTP_POST_VARS["Credit0Card0Type_required"] == "Visa" )

    echo " checked=\"checked\""; 

?> />

    </td>

  </tr>

  <tr>

    <td class="cart" align="right">MasterCard</td>

    <td class="cart">

      <input type="radio" name="Credit0Card0Type_required"

        value="MasterCard"
<?php if( isset($HTTP_POST_VARS["Credit0Card0Type_required"]) && $HTTP_POST_VARS["Credit0Card0Type_required"] == "MasterCard" ) echo " checked=\"checked\""; ?> /> </td> </tr> <tr> <td class="cart" align="right">American Express</td> <td class="cart"> <input type="radio" name="Credit0Card0Type_required" value="American Express" <?php if( isset($HTTP_POST_VARS["Credit0Card0Type_required"]) && $HTTP_POST_VARS["Credit0Card0Type_required"] == "American Express" ) echo " checked=\"checked\""; ?> /> </td> </tr> <tr> <td colspan="2"><hr noshade="noshade" /></td> </tr> <tr> <th class="cart" colspan="2">Expiration date:</th> </tr> <tr>

home / programming / carts / chap7 / 2 To page 1To page 2To page 3To page 4To page 5current pageTo 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 >
XML and PHP Simplified · Creating a ASP.NET Contact Form · Data Filtering with PHP
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Intel to Host Live Nehalem Q&A · 12 Tips to Troubleshoot Network File-Sharing · 10 Tips for Selling on Kijiji

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

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