How This Book Is Organized


There are 20 chapters and 8 appendixes in this book. Chapter 1 to Chapter 5 introduce web database applications, PHP, MySQL, and SQL:


Chapter 1

Discusses the three-tier architecture commonly used in web database applications, and how data is exchanged between browsers and servers. It introduces PHP and MySQL, and discusses when and why databases are used on the Web. The features of MySQL 4.1 and PHP5 are introduced.


Chapter 2

Introduces the PHP scripting language. It covers programming in PHP and discusses the basic programming constructs, variables, types, functions, and techniques.


Chapter 3

Explains the intermediate level features of PHP, including how to work with arrays, strings, and times and dates. The chapter is illustrated with many short examples that show how each technique is used in practice.


Chapter 4

Shows you how to use the basic object-oriented (OO) features of PHP4 and PHP5, and explains why OO programming is popular and becoming important in PHP. A more advanced discussion of the new OO features in PHP5 is presented in Chapter 14, but this chapter gives you all the knowledge you need to work with the PEAR packages that are discussed in Chapter 7.


Chapter 5

Introduces MySQL and how to interact with it using the SQL query language. The focus of the chapter is an example-driven section on querying, and we illustrate it using examples from the online winestore's database. We also introduce you to the basics of creating, deleting, and updating data and databases. A more advanced discussion of the features of MySQL 4.1 is presented in Chapter 15, but the basics discussed in this chapter are sufficient for you to work with all of the material up to Chapter 13 and with the online wines case study in Chapter 17 to Chapter 20.

Chapter 6 to Chapter 11 cover the principles and practice of developing web database application logic.


Chapter 6

Introduces connecting to MySQL with PHP. We explain the querying process used in most interactions with MySQL and present examples that use the PHP MySQL library functions. We show how user data is encoded, sent in requests from a web browser to a web server, and decoded for processing in PHP. We discuss the security implications in processing user data and show steps to secure interactive querying systems. Our discussions are supported by short examples that show you how to build simple query modules.


Chapter 7

Discusses the PEAR package repository. Packages are source code modules that can be used in your code and save you from reinventing widely used concepts. PEAR includes over 100 packages for tasks as diverse as date and time manipulation, security, networking, and database access, and this chapter shows you how to install and upgrade them. The chapter focuses on a templates package a useful tool for separating HTML from code and another for database abstraction. Both packages are used in later chapters to develop robust, reusable code.


Chapter 8

Covers writing data to web databases. There are several reasons why writing data is different from reading it and that's why it isn't discussed in Chapter 6. For example, reloading or printing a page from a web browser can cause data to be written to a database more than once. Multiple users accessing the same database introduces other problems, such as data unexpectedly being changed by one user while it's being read by another. We discuss how to solve problems related to the nature of the Web and multiple users. We illustrate the principles with a case study example of collecting form data from a user and saving it in a database.


Chapter 9

This chapter is related to Chapter 8 and presents the principles and techniques for user input validation. We show you techniques such as how to validate dates, credit card numbers, and phone numbers, and explain how to use these in error-checking modules that are scalable and practical for web database applications. We also introduce client-side, browser-based JavaScript and show you how to use it for common tasks including user input validation in the web browser.


Chapter 10

Covers the principles of adding session management to web database applications. Session management allows the interactions between a user and the application to be related so that, for example, a user can log in and log out of an application and be guided through a series of steps in a process. We show how PHP manages sessions and illustrate the techniques with a case study of managing error feedback to users. We also discuss when and when not to use sessions, and how to configure PHP's session handler so it's secure and scalable.


Chapter 11

Discusses web security and authentication. We show how PHP can be used for basic authentication, how databases can be used to manage users, and why you might need to secure communications with the secure sockets layer (SSL). The case study is a reusable authentication module with login, logout, and password change features.

Chapter 12 to Chapter 15 discuss tasks and techniques you'll need when you're building a real-world application or deploying an application to users.


Chapter 12

Error handling and debugging are the focus of this chapter. We discuss the types of errors that can occur in PHP and show you how to identify the source of common programming errors that cause these problems. We then show you how to write your own error handler that can be integrated into an application, and how to trigger your own errors when you need them. Adding a custom error handler gives a professional finish to an application.


Chapter 13

Discusses reporting for the Web and what solutions work in PHP. The focus is producing PDF (Adobe Portable Document Format) reports using a popular PHP PDF library, and we illustrate the techniques with several examples. The chapter concludes with a function reference for the class we use.


Chapter 14

This chapter shows you the advanced features of PHP5's object-oriented programming model. We extend the discussion in Chapter 4, and show you how to build and reuse classes, and how to write powerful OO applications. The chapter concludes with a case study that shows how all of the features can be used together to build a complex and powerful class hierarchy.


Chapter 15

This chapter shows you the advanced features of MySQL 4.1. It extends the discussion in Chapter 5, and shows you how to write complex queries, manipulate data in complex ways, manage users, and tune your database and MySQL server.

Chapter 16 to Chapter 20 present and outline the winestore case study that shows how most of the techniques discussed in the book are put together to build an application. The outlines aren't comprehensive: we assume you've read the book and understand the principles of developing web database applications.


Chapter 16

Explains the structure of the winestore application and discusses how the principles shown in earlier chapters are put together to build a real-world application that is flexible, robust, secure, and scalable. It also shows how the scripts work together through figures and explanations. We also explain how we've developed classes and functions for general-purpose tasks, and we list the code of all of the reusable components.


Chapter 17

Presents the code for customer management in the winestore. We list the scripts for collecting, validating, and modifying customer details, and show how new accounts are created.


Chapter 18

Presents the code for the shopping cart at the winestore. The shopping cart is stored in a database and each user's cart is tracked using the session techniques from Chapter 10. The cart module allows a user to view her cart, add items to the cart, update item quantities, delete items, and empty the cart.


Chapter 19

Presents the code for the ordering and shipping modules of the winestore. The ordering process shows how complex database processing is used to convert a shopping cart into a customer order. We also show how to validate credit card details, send an email confirmation of the order to the user, and show the confirmation as an HTML page.


Chapter 20

Concludes the winestore application by presenting the user authentication and searching modules. The user authentication module is almost identical to the one in Chapter 11. The searching and browsing module shows how to develop a component that presents a large number of results in separate pages and how to use previous and next functionality to move between the pages.

There are eight appendixes to this book:


Appendix A

A guide to installing the Apache web server, PHP, and MySQL on Linux platforms. Installation instructions change as software changes over time, so the latest version of this appendix can be downloaded at http://www.webdatabasebook.com/install-guides.


Appendix B

A guide to installing the Apache web server, PHP, and MySQL on Microsoft Windows platforms. Installation instructions change as software changes over time, therefore the latest version of this appendix can be downloaded at http://www.webdatabasebook.com/install-guides.


Appendix C

A guide to installing the Apache web server, PHP, and MySQL on Mac OS X platforms. Installation instructions change as software changes over time, so the latest version of this appendix can be downloaded at http://www.webdatabasebook.com/install-guides.


Appendix D

Describes the workings of the Web and explains how the HTTP protocol is used to transfer data between browsers and servers.


Appendix E

Contains a case study that models the system requirements for the winestore using entity-relationship database modeling. It shows how this model can be converted to a design. It also details the SQL statements used to create the winestore database.


Appendix F

An extension of Chapter 10, this appendix shows how the default PHP method for session handling (which uses disk files) can be moved into a database.


Appendix G

Lists useful resources, including web sites and books containing more information on the topics presented throughout this book.


Appendix H

A guide to PHP's new improved MySQL library, and how it makes use of the new features of MySQL 4.1.



Web Database Application with PHP and MySQL
Web Database Applications with PHP & MySQL, 2nd Edition
ISBN: 0596005431
EAN: 2147483647
Year: 2003
Pages: 176

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net