with Apache Installing PHP Files on Windows php.ini Basics Testing Your Installation Getting Installation Help The Basics of PHP Scripts Summary... Troubleshooting Your Installation
Trang 2Sams Teach Yourself PHP, MySQL and Apache All in One Table of Contents
Trang 3Conventions Used in This Book Part I: Laying the Groundwork Chapter 1 Installing and
Basic Security Guidelines
Introducing the MySQL
Trang 5Structure
Apache Log Files
Apache-Related Commands Starting Apache for the First Time
Trang 6with Apache
Installing PHP Files on
Windows
php.ini Basics
Testing Your Installation
Getting Installation Help
The Basics of PHP Scripts Summary
Trang 8Testing for the Existence of a
Trang 9Function
Summary
Q&A
Workshop
Chapter 7 Working with
Arrays and Objects
Trang 10Part III: Getting Involved with the Code
Chapter 8 Working with
Strings, Dates, and Times
Formatting Strings with PHP Investigating Strings in PHP Manipulating Strings with PHP Using Date and Time Functions
Trang 11User-Defined Arrays
Combining HTML and PHP Code on a Single Page
Using Hidden Fields to Save State
Redirecting the User
Sending Mail on Form
Trang 13Opening a File for Writing, Reading, or Appending
Reading from Files
Writing or Appending to a File Working with Directories
Trang 14Running Commands with
Drawing a New Image
Getting Fancy with Pie Charts Modifying Existing Images
Trang 15Chapter 14 Learning the
Database Design Process The Importance of Good
Database Design
Types of Table Relationships Understanding Normalization Following the Design Process Summary
Q&A
Trang 16to Modify Records
Using the REPLACE Command
Trang 17Using the DELETE Command Frequently Used String
Trang 18Workshop
Part V: Basic Projects
Chapter 17 Managing a Simple Mailing List
Developing the Subscription Mechanism
Developing the Mailing
Trang 20Scripts
Displaying the Topic List
Displaying the Posts in a Topic Adding Posts to a Topic
Trang 21Shopping Cart Mechanism Planning and Creating the Database Tables
Integrating the Cart with Your Storefront
Payment Methods and the Checkout Sequence
Trang 23Introducing Cookies
Setting a Cookie with PHP
Restricting Access Based on Cookie Values
Summary
Q&A
Workshop
Chapter 24 Logging and
Monitoring Web Server Activity Standard Apache Access
Trang 24Summary
Q&A
Trang 26Chapter 27 Setting Up a Secure Web Server
The Need for Security
Trang 27Optimizing Your Table
Structure
Optimizing Your Queries
Using the FLUSH Command Using the SHOW Command Summary
Trang 28What's Wrong With PHP 4? The New Object Model
Additional New Features
So, When Should I Upgrade to PHP 5?
Summary
Q&A
Chapter 31 Features and
Trang 29Part VIII: Appendix
Appendix A Installing MySQL, Apache, and PHP from the CD-
Trang 30ROM
Linux/Unix Installation Windows Installation Troubleshooting
Trang 31index_I index_J index_K index_L index_M index_N index_O index_P index_Q index_R index_S index_T index_U index_V
Trang 32index_W index_X index_Y index_Z
Trang 33Publisher : Sams Publishing
Pub Date : December 18, 2003
ISBN : 0-672-32620-5
Pages : 624
Trang 34In just a short time you can
learn how to use PHP, MySQL, and Apache together to create dynamic, interactive Web sites and applications using the three leading open-source Web
Trang 35previous ones, enabling you to learn the essentials of PHP scripting, MySQL databases, and the Apache Web server from the ground up.
Trang 36Publisher : Sams Publishing
Pub Date : December 18, 2003
ISBN : 0-672-32620-5
Pages : 624
Trang 37Who Should Read This Book?
How This Book Is Organized
Conventions Used in This Book
Part I Laying the Groundwork
Chapter 1 Installing and Configuring MySQL Current and Future Versions of MySQL How to Get MySQL
Installing MySQL on Linux/Unix
Installing MySQL on Windows
Trang 38Troubleshooting Your Installation
Basic Security Guidelines
Introducing the MySQL Privilege System Working with User Privileges
Installing Apache on Linux/Unix
Installing Apache on Windows
Apache Configuration File Structure Apache Log Files
Trang 39Chapter 3 Installing and Configuring PHP Current and Future Versions of PHP Building PHP on Linux/Unix with Apache Installing PHP Files on Windows
php.ini Basics
Testing Your Installation
Getting Installation Help
The Basics of PHP Scripts
Summary
Q&A
Workshop
Part II PHP Language Structure
Chapter 4 The Building Blocks of PHP Variables
Trang 41Chapter 7 Working with Arrays and Objects What Is an Array?
Part III Getting Involved with the Code
Chapter 8 Working with Strings, Dates, and Times Formatting Strings with PHP
Investigating Strings in PHP
Manipulating Strings with PHP
Using Date and Time Functions in PHP
Summary
Workshop
Chapter 9 Working with Forms
Creating a Simple Input Form
Trang 42Accessing Form Input with User-Defined Arrays Combining HTML and PHP Code on a Single Page Using Hidden Fields to Save State
Redirecting the User
Sending Mail on Form Submission
Working with File Uploads
Summary
Workshop
Chapter 10 Working with User Sessions
Session Function Overview
Starting a Session
Working with Session Variables
Passing Session IDs in the Query String
Destroying Sessions and Unsetting Variables Summary
Trang 43Creating and Deleting Files
Opening a File for Writing, Reading, or Appending Reading from Files
Writing or Appending to a File
Working with Directories
Running Commands with system() or passthru()
Summary
Q&A
Workshop
Chapter 13 Working with Images
Understanding the Image-Creation Process Necessary Modifications to PHP
Drawing a New Image
Getting Fancy with Pie Charts
Trang 44Modifying Existing Images
Summary
Q&A
Workshop
Part IV PHP and MySQL Integration
Chapter 14 Learning the Database Design Process The Importance of Good Database Design Types of Table Relationships
Learning the Table Creation Syntax
Using the INSERT Command
Using the SELECT Command
Trang 45Using WHERE in Your Queries
Selecting from Multiple Tables
Using the UPDATE Command to Modify Records Using the REPLACE Command
Using the DELETE Command
Frequently Used String Functions in MySQL Using Date and Time Functions in MySQL Summary
Part V Basic Projects
Chapter 17 Managing a Simple Mailing List Developing the Subscription Mechanism Developing the Mailing Mechanism
Summary
Trang 46Q&A
Workshop
Chapter 18 Creating an Online Address Book Planning and Creating the Database Tables Creating a Menu
Creating the Record Addition Mechanism Viewing Records
Creating the Record Deletion Mechanism Adding Subentries to a Record
Summary
Workshop
Chapter 19 Creating a Simple Discussion Forum Designing the Database Tables
Creating the Input Forms and Scripts
Displaying the Topic List
Displaying the Posts in a Topic
Adding Posts to a Topic
Summary
Chapter 20 Creating an Online Storefront
Trang 47Planning and Creating the Database Tables Displaying Categories of Items
Payment Methods and the Checkout Sequence Summary
Workshop
Chapter 22 Creating a Simple Calendar
Building a Simple Display Calendar
Creating a Calendar Library
Trang 48Using Apache for Access Control
Combining Apache Access Methods
Limiting Access Based on HTTP Methods
Introducing Cookies
Setting a Cookie with PHP
Restricting Access Based on Cookie Values
Standard Apache Error Logging
Managing Apache Logs
Logging Custom Information to a Database
Summary
Q&A
Workshop
Chapter 25 Application Localization
About Internationalization and Localization
About Character Sets
Trang 49Part VI Administration and Fine Tuning
Chapter 26 Apache Performance Tuning and Virtual Hosting Scalability Issues
Load Testing with ApacheBench
Proactive Performance Tuning
Preventing Abuse
Implementing Virtual Hosting
Summary
Q&A
Chapter 27 Setting Up a Secure Web Server
The Need for Security
The SSL Protocol
Obtaining and Installing SSL Tools
Managing Certificates
Trang 50MySQL Startup Options
Optimizing Your Table Structure
Optimizing Your Queries
Using the FLUSH Command
Using the SHOW Command
Summary
Q&A
Workshop
Chapter 29 Software Upgrades
Staying in the Loop
Trang 51Part VII Looking Toward the Future
Chapter 30 Features and Backward Compatibility of PHP 5.0
What's Wrong With PHP 4?
The New Object Model
Additional New Features
So, When Should I Upgrade to PHP 5?
Additional New Functionality
Looking Further Ahead to MySQL 5.0
Summary
Q&A
Workshop
Part VIII Appendix
Appendix A Installing MySQL, Apache, and PHP from the CD-ROM Linux/Unix Installation
Trang 52Windows Installation Troubleshooting Index
Trang 53Copyright © 2004 by Sams Publishing
All rights reserved No part of this bookshall be reproduced, stored in a retrievalsystem, or transmitted by any means,
electronic, mechanical, photocopying,recording, or otherwise, without writtenpermission from the publisher No patentliability is assumed with respect to the use
of the information contained herein
Although every precaution has been taken
in the preparation of this book, the
publisher and author assume no
responsibility for errors or omissions.Nor is any liability assumed for damagesresulting from the use of the information
Trang 55should not be regarded as affecting thevalidity of any trademark or service mark.
Warning and Disclaimer
Every effort has been made to make thisbook as complete and as accurate aspossible, but no warranty or fitness isimplied The information provided is on
an "as is" basis The author and the
publisher shall have neither liability norresponsibility to any person or entity withrespect to any loss or damages arisingfrom the information contained in thisbook or from the use of the CD or
programs accompanying it
Trang 56Bulk Sales
Sams Publishing offers excellent discounts
on this book when ordered in quantity forbulk purchases or special sales For moreinformation, please contact
U.S Corporate and Government Sales
Trang 60About the Authors
Lead author
Contributing authors
Trang 61programming languages and databasetopics, and you can find translations of herwork in several languages, includingChinese, Italian, Portuguese, Polish, andeven Serbian.
Trang 62Contributing authors
Matt Zandstra is a writer and consultantspecializing in server programming Withhis business partner, Max Guglielmino, heruns Corrosive
(http://www.corrosive.co.uk), a technicalagency that plans, designs and builds
Internet applications Matt is interested inall aspects of object-oriented
programming, and is currently exploringenterprise design patterns for PHP 5.When he is not reading, writing, or
thinking about coding in PHP and Java,Matt shoots alien invaders in the park withhis four-year-old daughter, Holly Helives by the sea in Brighton, Great Britain,with his partner Louise McDougall, and
Trang 63their children Holly and Jake.
Daniel López Ridruejo is the founder ofBitRock, a technology company providingmultiplatform installation and managementtools for a variety of commercial and opensource software products Previously, hewas part of the original engineering team
at Covalent Technologies, Inc., whichprovides Apache software, support, andservices for the enterprise He is the
author of several popular Apache andLinux guides, the mod_mono module forintegrating Apache and NET, and of
Comanche, a GUI configuration tool forApache Daniel is a regular speaker atopen source conferences such as LinuxWorld, ApacheCon, and the O'Reilly
Trang 64Open Source Convention He holds aMaster of Science degree in
Telecommunications from the EscuelaSuperior de Ingenieros de Sevilla andDanmarks Tekniske Universitet Daniel is
a member of the Apache Software
Foundation
Trang 65The Apache Foundation, the PHP Group,and MySQL AB deserve much morerecognition than they ever get for creatingthese super products that drive a greatportion of the Web
Daniel Lòpez (author of Sams Teach
Yourself Apache 2 in 24 Hours) and Matt
Zandstra (author of Sams Teach Yourself
PHP in 24 Hours) wrote super books,
which form a portion of this book
Obviously, this book would not existwithout their work!
Great thanks especially to all the editorsand layout folks at Sams who were
Trang 66involved with this book, for all their hardwork in seeing this through! Thanks asalways to everyone at i2i Interactive fortheir never-ending support and
encouragement
Trang 67We Want to Hear from You!
As the reader of this book, you are our
most important critic and commentator
We value your opinion and want to knowwhat we're doing right, what we could dobetter, what areas you'd like to see uspublish in, and any other words of
wisdom you're willing to pass our way
You can email or write me directly to let
me know what you did or didn't like aboutthis bookas well as what we can do tomake our books stronger
Please note that I cannot help you with
Trang 68technical problems related to the topic of this book, and that due to the high
volume of mail I receive, I might not be able to reply to every message.
When you write, please be sure to includethis book's title and author as well as yourname and phone or email address I willcarefully review your comments and sharethem with the author and editors whoworked on the book
Trang 70Reader Services
For more information about this book orothers from Sams Publishing, visit ourWeb site at www.samspublishing.com.Type the ISBN (excluding hyphens) or thetitle of the book in the Search box to findthe book you're looking for
Trang 71Welcome to Sams Teach Yourself PHP,
MySQL, and Apache All in One! This
book combines the lessons found in Sams
Teach Yourself Apache 2 in 24 Hours, Sams Teach Yourself PHP in 24 Hours,
and Sams Teach Yourself MySQL in 24
Hours, along with several additional
chapters, to provide you with a solid andpainless introduction to the world ofdeveloping Web-based applications usingthese three technologies
Over the course of this book, you'll learnthe concepts necessary for configuring andmanaging Apache, the basics of
programming in PHP, and the methods for
Trang 72using and administering the MySQL
relational database system The overallgoal of the book is to provide you with thefoundation you need to understand howseamlessly these technologies integratewith one another, and to give you practicalknowledge of how to integrate them
Trang 73Who Should Read This
Book?
This book is geared toward individualswho possess a general understanding ofthe concepts of working in a Web-baseddevelopment environment, be it
Linux/Unix or Windows Installation andconfiguration lessons assume that youhave familiarity with your operating
system and the basic methods of building(on Linux/Unix systems) or installing (onWindows systems) software
The lessons that delve into programmingwith PHP assume no previous knowledge
of the language, but if you have experiencewith other programming languages, such