Notes on This Edition
The entire contents of this edition of the book were updated to correspond to version 5.3 of PHP and version 5.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 10% or so of the material requires version 5.3 of PHP, although in those instances, I do provide alternative code for earlier versions of the language.
In terms of what’s new, there are three entirely new chapters. Chapter 6: Database Design takes some material out of a couple of chapters in the previous edition, breaks it down into smaller steps, and creates a more cohesive discussion of every key facet of database design. Chapter 15: Introducing jQuery is entirely new, introducing JavaScript and the jQuery framework. The examples include form validation, event handling, and Ajax. Chapter 16: An OOP Primer is also entirely new, discussing the basics of object-oriented programming in PHP. The focus is really on basic ideas and syntax, using existing classes (OOP design and theory requires too many pages to fit into this book).
In terms of revised content, every chapter now ends with a “Review and Pursue” section which asks questions that stress key points and provides prompts for how you can expand upon the information you just learned. A few chapters use new examples, mostly because I was bored with the existing ones. Chapter 7: Advanced SQL and MySQL has expanded coverage of JOINs, a new section on advanced selections, and more. In fact, updating and expanding the MySQL and SQL content was a key change in this edition. Chapter 11: Web Application Development is heavily rewritten, putting more emphasis on the use of JavaScript in the example application partially developed in that chapter. Chapter 13: Security Methods has two new security examples: using the Filter extension and validating file uploads by type. Finally, Appendix A: Installation has a new section on Apache server configuration. To save space, the Appendix is being made available for free online from the book’s publisher, Peachpit Press (I’ll provide more details once I have them).
- Introduction
- Chapter 1: Introduction to PHP
- Basic Syntax
- Sending Data to the Web Browser
- Writing Comments
- What Are Variables?
- Introducing Strings
- Concatenating Strings
- Introducing Numbers
- Introducing Constants
- Single vs. Double Quotation Marks
- Basic Debugging Steps
- Review and Pursue
- 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
- Review and Pursue
- Chapter 3: Creating Dynamic Web Sites
- Including Multiple Files
- Handling HTML Forms, Revisited
- Making Sticky Forms
- Creating Your Own Functions
- Review and Pursue
- Chapter 4: Introduction to MySQL
- Naming Database Elements
- Choosing Your Column Types
- Choosing Other Column Properties
- Accessing MySQL
- Review and Pursue
- 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
- Review and Pursue
- Chapter 6: Database Design
- Normalization
- Creating Indexes
- Using Different Table Types
- Languages and MySQL
- Time Zones and MySQL
- Foreign Key Constraints
- Review and Pursue
- Chapter 7: Advanced SQL and MySQL
- Performing Joins
- Grouping Selected Results
- Advanced Selections
- Performing FULLTEXT Searches
- Optimizing Queries
- Performing Transactions
- Database Encryption
- Review and Pursue
- Chapter 8: 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
- Review and Pursue
- Chapter 9: 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
- Review and Pursue
- Chapter 10: Common Programming Techniques
- Sending Values to a Script
- Using Hidden Form Inputs
- Editing Existing Records
- Paginating Query Results
- Making Sortable Displays
- Review and Pursue
- Chapter 11: Web Application Development
- Sending Email
- Handling File Uploads
- PHP and JavaScript
- Understanding HTTP Headers
- Date and Time Functions
- Review and Pursue
- Chapter 12: Cookies and Sessions
- Making a Login Page
- Defining the Login Functions
- Using Cookies
- Using Sessions
- Improving Session Security
- Review and Pursue
- Chapter 13: Security Methods
- Preventing Spam
- Validating Data by Type
- Validating Files by Type
- Preventing XSS Attacks
- Using the Filter Extension
- Preventing SQL Injection Attacks
- Review and Pursue
- Chapter 14: 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
- Review and Pursue
- Chapter 15: Introducing jQuery
- What is jQuery?
- Incorporating jQuery
- Using jQuery
- Selecting Page Elements
- Event Handling
- DOM Manipulation
- Using Ajax
- Review and Pursue
- Chapter 16: An OOP Primer
- Fundamentals and Syntax
- Working with MySQL
- The DateTime Class
- Review and Pursue
- Chapter 17: Example—Message Board
- Making the Database
- Writing the Templates
- Creating the Index Page
- Creating the Forum Page
- Creating the Thread Page
- Posting Messages
- Review and Pursue
- Chapter 18: 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
- Review and Pursue
- Chapter 19: Example—E-Commerce
- Creating the Database
- The Administrative Side
- Creating the Public Template
- The Product Catalog
- The Shopping Cart
- Recording the Orders
- Review and Pursue
- Appendix A: Installation(AVAILABLE ONLINE)
- Installation on Windows
- Installation on Mac OS X
- Managing MySQL Users
- Testing Your Installation
- Configuring PHP
- Configuring Apache