Home > Store > Databases > MySQL
Core Web Application Development with PHP and MySQL
- By Marc Wandschneider
- Published Sep 26, 2005 by Prentice Hall. Part of the Core Series series.
- Copyright 2006
- Dimensions: 7x9-1/4
- Pages: 912
- Edition: 1st
- Book
- ISBN-10: 0-13-186716-4
- ISBN-13: 978-0-13-186716-1
Register your product to gain access to bonus material or receive a coupon.
The programmer's Guide to building robust web applications with PHP and MySQL
This is a comprehensive, practical guide for programmers who want to develop production-quality, database-enabled web applications with PHP and MySQL. Long-time developer Marc Wandschneider systematically addresses the entire process: not only coding, but also upfront application, user interface and database design, PLUS security, testing, and more.
You'll walk through building three applications from start to finish: a calendaring system, a weblog engine, and an e-commerce store. Along the way, you'll master essential strategies for creating robust web database applications and learn how to avoid the common pitfalls that trip up many developers moving to PHP and MySQL.
- Starts with a complete primer on PHP for developers including coverage of code organization, reuse, and object-oriented PHP
- Contains detailed treatments of data access, including transactions, foreign keys, and indexes
- Presents powerful data validation techniques utilizing PHP regular expressions
- Walks through planning web applications, including user interfaces and user management
- Offers systematic guidance on securing web applications from end to end
- Covers a wide range of implementation issues including internationalization, error handling, data validation, debugging, session management, and deployment
- Includes detailed chapters on XML, XML-based web services, and the PEAR framework for reusable PHP components
- Shows how to work with the Oracle and PostgreSQL databases
Sample Chapter(s)
Download the Sample
Chapter related to this title.
Index
Download the Index
file related to this title.
Preface
With that in mind, I sat down to write this book and explain how to use the various technologies that go into writing web applications. I have made every mistake possible while learning about PHP and databases, and have therefore tried to incorporate as much of what I learned into this book. Far too many books published these days are merely a reprint of existing documentation or UNIX man pages, and I truly wanted to see something different in print.
The technologies, however, are only half the battle. Without strategies or systematic approaches to design and implementation, applications are doomed to an expensive and messy existence at bestor failure at worst. Therefore, this book focuses on a lot of things you might not see covered to the same extent in other booksdesign, testing, and security.
Target Audience
This book is targeted at people who need or want to write a web application. You might be a corporate developer looking to build an intranet application for your company or an Internet web application for customers. You might be a consultant helping a small business develop a web store, or just a hobbyist looking to learn more about web applications and write one of your own.The assumption is that you have at least a passing familiarity with programming, although this book by no means expects you to be an expert. An understanding of basic programming constructs, such as variables and functions, and a basic understanding of HTML should be more than sufficient.
Because I knew next to nothing about databases when I started learning about web application programming, I likewise expect no more of the reader. This book covers databases from basic terminology and design to basic and advanced queries, with an appropriate balance between clear-and-simple instruction and interesting examples to help you in your development.
About PHP
PHP began in 1994 as a series of scripts called PHP/FI (Personal Home Page/Forms Interpreter), and it was written by a fellow named Rasmus Lerdorf to help him manage documents on his web site. Over the years, PHP grew into something more serious. In 1997, a second version of the system came out with additional functionality.In late 1998, PHP 3.0 was released, leading to a major rewrite of the code and the involvement of two new developersZeev Suraski and Andi Gutmans. The goal was to support progressively broader and more complex applications on the web. In early 2000, version 4.0 was released. Based on a new language engine called the Zend Engine, this version had much better performance and increased code modularity. By late 2004, the much-evolved version 5.0 was released. It included many new features, such as new language constructs, broader web server support, sessions, and additional third-party extensions. Among the new language features was a significantly improved and expanded object-oriented programming model, which this book uses extensively. Somewhere along the way, PHP ceased to refer to "Personal Home Page" and came to mean "PHP Hypertext Preprocessor," a so-called recursive acronym. (The acronym actually forms part of the term it defines!)
PHP is a remarkably productive languageyou can sit down and crank out (yes, that's the technical term) large amounts of code in a short period of time, and this productivity is what drew me to it some years back. With PHP, I was able to put together surprisingly robust and dynamic travelogues of my journeys to various countries with relatively little code.
The one possible "fly in the ointment" is that the language can be quirky compared to other programming languagesespecially if you, like me, come from a background of languages more similar to C/C++, Java, or Visual BASIC. In fact, many of the things covered in this book are the result of my sitting around and scratching my head for a couple of hours. However, after you become comfortable with it, the language proves fun to write and is surprisingly powerful.
Layout
This book is divided into six parts, which represents the logical progression of writing web applications.Part I, "The Basics of PHP," covers the PHP language itself, starting with descriptions and discussions of the most basic types of language. Part I then moves on to functions, code structure, and object-oriented programmingbefore finishing off with a discussion of arrays and strings.
Part II, "Database Basics," covers databases, starting with terminology and progressing through design and data definition. Part II finishes by describing the use of databases and tables, ranging from the most basic queries to transactions and functions.
Part III, "Planning Web Applications," takes a step back from coding to discuss the design of your web applications. Many people get so involved in writing their code that they forget to sit down and actually think about it in advance. These chapters (hopefully) give you something to think about as you begin. This part also focuses heavily on securing your applications, as it is not something to be taken lightly.
Part IV, "Implementing Your Web Application," discusses the more advanced language features and concepts required to move beyond simple PHP and databases into writing web applications, covering topics such as errors, sessions, and XMLincluding plenty of sample code.
Part V, "Sample Projects and Further Ideas," presents three full web application samples that start with a simple appointment management system, progress through a web log system, and finish with an ecommerce store. These samples incorporate much of what the book has covered and are designed to be robust. Instead of killing large numbers of trees and listing all the code for the samples, you can download and run them. The book shows you only the most salient sections of the code and leaves you to download and run them in completion.
Part VI, "Appendixes," discusses the installation of the necessary software to run your web applications and how to perform various database actions on different database engines, and suggests some additional reading material.
Before You Begin
Before you begin reading the meat of this book, please take a moment to open the CD that accompanies this book and copy the source code to your computer. The phpwasrc/ directory contains the initial files you need.In addition to the full source code (and installation instructions) for the three large samples from Part V of the book, there are also small snippets of code to accompany many of the chapters in the book. You can run these, debug them, or change and play with them to further help you learn how the language works.
Beyond the sample sources, the CD contains versions of PHP, the Apache HTTP Server, and MySQL that you can use to install the software on your local machine. Instructions are included on the CD.
Table of Contents
Introduction.
I. THE BASICS OF PHP.
1. Getting Started with PHP.
2. The PHP Language.
3. Code Organization and Reuse.
4. Object-Oriented Programming.
5. Working with Arrays.
6. Strings and Characters of the World.
7. Interacting with the Server: Forms.
II. DATABASE BASICS.
8. Introduction to Databases.
9. Designing and Creating Your Database.
10. Using Databases: Storing and Retrieving Data.
11. Using Databases: Advanced Data Access.
12. PHP and Data Access.
III. PLANNING WEB APPLICATIONS.
13. Web Applications and the Internet.
14. Implementing a User Interface.
15. User Management.
16. Securing Your Web Applications: Planning and Code Security.
17. Securing Your Web Applications: Software and Hardware Security.
IV. IMPLEMENTING YOUR WEB APPLICATION.
18. Error Handling and Debugging.
19. Cookies and Sessions.
20. User Authentication.
21. Advanced Output and Output Buffering.
22. Data Validation with Regular Expressions.
23. XML and XHTML.
24. Files and Directories.
25. File Uploading.
26. Working with Dates and Times.
27. XML Web Services and SOAP.
28. Using PEAR.
29. Development and Deployment.
V. SAMPLE PROJECTS AND FURTHER IDEAS.
30. Strategies for Successful Web Applications.
31. An Appointment Manager.
32. A Blogging Engine.
33. An Ecommerce Application.
VI. APPENDIXES.
Appendix A. Installation/Configuration.
Appendix B. Database Function Equivalents.
Appendix C. Recommended Reading.
Index.
This book includes Instant Online Access with
and free shipping!
Instant Online Access with Safari Books Online
With your book purchase you are entitled to free, instant online access to that book on Safari Books Online for 45 days. After you've completed your purchase, you will receive instructions on how to log into Safari Books Online. If you do not want to receive online access to the book, simply uncheck the box for Instant Online Access in your cart.
- Save more by becoming a member.
- Request an Instructor or Media review copy.
- Corporate, Academic, and Employee Purchases
- International Buying Options
Online access to books, videos, and tutorials from Addison Wesley, Prentice Hall, Cisco Press, IBM Press, O'Reilly Media and others - starting as low as $22.99. Learn more and start a free trial.



Account Sign In
View your cart