Chapter 16. Hugh and Dave's Online Wines:A Case Study

This chapter is the first of five that outline the major case study for this book, Hugh and Dave's Online Wines. It contains an overview of the system requirements, a walk-through of the complete application, and a pointer to where the fundamentals of each component are explained in the book. It also explains most of the components we've developed for reuse throughout the application.

The material presented in the winestore chapters doesn't fully explain the application. Also, we avoid duplicating our discussions of the principles and basic techniques for building web database applications. Chapter 2 through Chapter 13 are required background reading to fully understand the implementations.

To make implementing the winestore a little simpler, we've developed two template classes. They inherit from PEAR's ITX templates and are designed to give every winestore page a generic framework. In particular, our form class includes code for creating form widgets that can report errors and display previously entered data. We explain how we use these classes in this chapter, and list the code and the templates. We also discuss our functions for general-purpose validation, our custom error handler, database settings, and general-purpose functions and constants.

Before you begin this chapter, we recommend downloading and installing the online winestore on a local machine following the instructions in Appendix A to Appendix C. The best way to understand the code is to have a local copy of the application, to open the scripts in an editor, and to walk through the scripts while using the application with a browser. Modifications of the scripts are encouraged. Suggestions are welcome by email to

The source code to the winestore application (and all other code in this book) can be redistributed as long as it continues to include a statement that it's from Hugh E. Williams and David Lane, Web Database Application with PHP and MySQL, Second Edition, published by O'Reilly & Associates. You're welcome to use it for any purpose with one exception: it cannot be included in any other book, publication, or educational product without permission from O'Reilly & Associates. No warranty is attached, and we can't take responsibility for errors or fitness for use.