Notes on This Edition
The entire contents of this edition of the book were updated to correspond to version 6 of PHP and version 5 of MySQL. Approximately 50% of the material requires version 5 or later of PHP, mostly because the book only uses the Improved MySQL functions, added in PHP 5 and MySQL 4.1. Another 20% or so of the material requires version 6 of PHP. This 20% reflects the bulk of the new material in this edition.
In terms of what’s new, there are five entirely new chapters. Chapter 4: Introduction to MySQL takes some material out of the previous edition, breaks it down into smaller steps, and adds a discussion of phpMyAdmin. Chapter 12: Security Methods is entirely new, focusing on addressing specific security concerns (although some of the material is from previous editions). Chapter 13: Perl-compatible Regular Expressions is also entirely new, discussing a different (more or less preferred) type of regular expressions. The bulk of the new Chapter 14: Making Universal Sites is Unicode, support for which has been added in PHP 6. The chapter also has discussion of using time zones in MySQL and locales in PHP. Chapter 15: Example—Message Board is a new example chapter, creating a mulit-lingual forum.
In terms of revised content, Chapter 6: Advanced SQL and MySQL uses an entirely new example–a message board/forum–for all of the steps and SQL queries. Every chapter that uses both PHP and MySQL together, which is about half the book, has been updated to use the Improved MySQL functions instead of the older MySQL functions. Chapter 11: Cookies and Sessions handles the login/logout process a bit differently. Chapter 16: Example—User Registration has been updated to support different levels of users. Chapter 17: Example—E-Commerce and a couple of other chapters make more use of sticky forms, a concept that’s much more thoroughly covered in this edition. Finally, the Windows installation instructions in Appendix A: Installation have been updated to use XAMPP, a truly great (and free!) product.
The astute observer will see that this edition is actually shorter than the second edition. There are several reasons for this. First, PHP 6 removes support for some features and so those features are no longer addressed in this book (notably, these are Magic Quotes and Register Globals). Second, I dropped the last two appendixes. One was just a reprinting of tables from elsewhere in the book and the other listed resources readily found online. Third, I dropped maybe 20 pages or so of material that was more confusing than explanatory. This includes discussions of PHP’s error_log() function and validating forms using JavaScript. These topics, as well as any other dropped content, aren’t things I regularly use in my Web development, so the book isn’t lacking for their omission. Finally, I made some adjustments as to how I wrote and formatted the book in order to be able to fit more information into fewer pages.
- Introduction
- Chapter 1: Introduction to PHP
- Basic Syntax
- Sending Data to the Web Browser
- Understanding PHP, HTML, and White Space
- Writing Comments
- What Are Variables?
- Introducing Strings
- Concatenating Strings
- Introducing Numbers
- Introducing Constants
- Single vs. Double Quotation Marks
- Chapter 2: Programming with PHP
- Creating an HTML Form
- Handling an HTML Form
- Conditionals and Operators
- Validating Form Data
- Introducing Arrays
- For and While Loops
- Chapter 3: Creating Dynamic Web Sites
- Including Multiple Files
- Handling HTML Forms, Revisited
- Making Sticky Forms
- Creating and Calling Your Own Functions
- Chapter 4: Introduction to MySQL
- Naming Database Elements
- Choosing Your Column Types
- Choosing Other Column Properties
- Accessing MySQL
- Chapter 5: Introduction to SQL
- Creating Databases and Tables
- Inserting Records
- Selecting Data
- Using Conditionals
- Using LIKE and NOT LIKE
- Sorting Query Results
- Limiting Query Results
- Updating Data
- Deleting Data
- Using Functions
- Chapter 6: Advanced SQL and MySQL
- Database Design
- Performing Joins
- Grouping Selected Results
- Creating Indexes
- Using Different Table Types
- Performing FULLTEXT Searches
- Performing Transactions
- Chapter 7: Error Handling and Debugging
- Error Types and Basic Debugging
- Displaying PHP Errors
- Adjusting Error Reporting in PHP
- Creating Custom Error Handlers
- PHP Debugging Techniques
- SQL and MySQL Debugging Techniques
- Chapter 8: Using PHP with MySQL
- Modifying the Template
- Connecting to MySQL
- Executing Simple Queries
- Retrieving Query Results
- Ensuring Secure SQL
- Counting Returned Records
- Updating Records with PHP
- Chapter 9: Common Programming Techniques
- Sending Values to a Script
- Using Hidden Form Inputs
- Editing Existing Records
- Paginating Query Results
- Making Sortable Displays
- Chapter 10: Web Application Development
- Sending Email
- Date and Time Functions
- Handling File Uploads
- PHP and JavaScript
- Understanding HTTP Headers
- Chapter 11: Cookies and Sessions
- Making a Login Page
- Defining the Login Functions
- Using Cookies
- Using Sessions
- Improving Session Security
- Chapter 12: Security Methods
- Preventing Spam
- Validating Data by Type
- Preventing XSS Attacks
- Preventing SQL Injection Attacks
- Database Encryption
- Chapter 13: Perl-compatible Regular Expressions
- Creating a Test Script
- Defining Simple Patterns
- Using Quantifiers
- Using Character Classes
- Finding All Matches
- Using Modifiers
- Matching and Replacing Patterns
- Chapter 14: Making Universal Sites
- Character Sets and Encoding
- Creating Multilingual Web Pages
- Unicode in PHP
- Collation in PHP
- Transliteration in PHP
- Languages and MySQL
- Time Zones and MySQL
- Working with Locales
- Chapter 15: Example—Message Board
- Making the Database
- Writing the Templates
- Creating the Index Page
- Creating the Forum Page
- Creating the Thread Page
- Posting Messages
- Chapter 16: Example—User Registration
- Creating the Templates
- Writing the Configuration Scripts
- Creating the Home Page
- Registration
- Activating an Account
- Logging In and Logging Out
- Password Management
- Chapter 17: Example—E-Commerce
- Creating the Database
- The Administrative Side
- Creating the Public Template
- The Product Catalog
- The Shopping Cart
- Recording the Orders
- Appendix A: Installation
- Installation on Windows
- Installation on Mac OS X
- MySQL Permissions
- Testing Your Installation
- Configuring PHP