Customer Management
In this section, we outline the customer
management scripts customer.1,
customer.2, and customer.3.
The customer.2 script is for data entry of
customer details and reporting errors and is based on the customer
<form>
case study from Chapter 6 and Chapter 8. The
customer.1 script performs data validation and
writes the customer details to the winestore database. It is also
based on the case study examples from Chapter 6 and Chapter 8. The
customer.3 receipt is designed to avoid the
reload problem after writing to the database.
Customer Validation
Example 10-1 lists the customer.1 script. It is based on Example 8-4 and has the same structure with two exceptions:
It validates a superset of customer fields, that is, all the fields listed in Chapter 1.
It manages the encryption of passwords and user account allocation.
The validation techniques used for the additional fields—such as the telephone and fax numbers, email address, zip code, and so on—are discussed in Chapter 7.
Example 10-1. The complete winestore customer validation script, customer.2
<?php // This script validates customer data entered into // example.customer.2.php. // If validation succeeds, it INSERTs or UPDATEs // a customer and redirect to a receipt page; if it // fails, it creates error messages and these are later // displayed by example.customer.2.php. include 'include.inc'; set_error_handler("errorHandler"); // Initialize a session session_start( ); // Register an error array - just in ...
Get Web Database Applications with PHP, and MySQL now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.