Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 641 trang
THÔNG TIN TÀI LIỆU
Cấu trúc
PHP 6 and MySQL 5 for Dynamic Web Sites
Table of Contents
Introduction
What Are Dynamic Web Sites?
What You'll Need
About This Book
Companion Web Site
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
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 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
Making 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
Index
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Z
Nội dung
[...]... companies will likely make a quick transition from PHP 4 to PHP5 to PHP 6 To discuss what’s new in PHP 6, I’ll start with the even bigger differences between PHP 4 and5 What Are Dynamic Web Sites? What’s new in PHP6 Put simply, when it comes to developing dynamic Web sites, PHP is better, faster, and easier to learn than the alternatives What you get with PHP is excellent performance, a tight integration... Introduction The MySQL software consists of several pieces, including the MySQL server (mysqld, which runs and manages the databases), the MySQL client (mysql, which gives you an interface to the server), and numerous utilities for maintenance and other purposes PHP has always had good support for MySQL, and that is even more true in the most recent versions of the language MySQL has been known to handle databases... in PHP5 involve object-oriented programming (OOP).Those changes don’t really impact this book, as OOP isn’t covered (I do so in my book PHP5 Advanced: Visual QuickPro Guide) With respect to this book, the biggest change in PHP5 is the addition of the Improved MySQL Extension, which is used to communicate with MySQL The Improved MySQL Extension offers many benefits over the older MySQL extension and. .. Press, 20 06) or search the Web ■ There are actually three different pairs of PHP tags Besides the formal (< ?php and ?>), there are the short tags (), and the script style ( and ) This last style is rarely used, and the formal style is recommended ■ Because I am running PHP on my own computer, you will sometimes see URLs like http://127.0.0.1:8000/first .php in this... PHP6 is support for Unicode, which is to say that PHP can now handle characters in every language in the world This is huge, and it’s also one of the reasons it’s taken a while to release PHP6 What this means in terms of programming is covered in Chapter 14, “Making Universal Sites.” The information in that chapter is also used in Chapter 15, “Example—Message Board.” Beyond Unicode support, PHP6. .. as 60 ,000 tables with more than five billion rows MySQL can work with tables as large as eight million terabytes on some operating systems, generally a healthy 4 GB At the time of this writing, MySQL is on version 5. 0. 45, with versions 5. 1 and6. 0 in development The version of MySQL you have affects what features you can use, so it’s important that you know what you’re working with For this book, MySQL. .. xiii Introduction What is MySQL? What Are Dynamic Web Sites? MySQL (www .mysql. com, Figure i.4) is the world’s most popular open-source database In fact, today MySQL is a viable competitor to the pricey goliaths such as Oracle and Microsoft’s SQL Server Like PHP, MySQL offers excellent performance, portability, and reliability, with a moderate learning curve and little to no cost MySQL is a database management... working with For this book, MySQL5. 0. 45 was used, although you should be able to do everything in this book as long as you’re using a version of MySQL greater than 4.1 (My book MySQL: Visual QuickStart Guide goes into the more advanced and newer features of MySQL5 that aren’t used in this book.) What Are Dynamic Web Sites? Client otherwise MySQL is used by NASA and the United States Census Bureau,... knowledge and builds upon many things taught here The MySQL book focuses almost exclusively on MySQL (there are but two chapters that use PHP) With that in mind, read the section “Is this book for you?” and see if the requirements apply If you have no programming experience at all and would prefer to be taught PHP more gingerly, my first book would be better If you are already very comfortable with PHP and. .. server as PHP (meaning the PHP interpreter will process the code) Any text outside of the PHP tags is immediately sent to the Web browser as regular HTML Along with placing PHP code within PHP tags, your PHP files must have a proper extension The extension tells the server to treat the script in a special way, namely, as a PHP page Most Web servers will use html or htm for standard HTML pages, and normally, . new in PHP 6 Because of the planned extinction of PHP 4, many users and Web hosting companies will likely make a quick transition from PHP 4 to PHP 5 to PHP 6. To discuss what’s new in PHP 6, I’ll. bigger differ- ences between PHP 4 and 5. PHP 5, like PHP 4 before it, is a major new development of this popular programming language. The most critical changes in PHP 5 involve object-oriented. . . . . . . . . . . . . 55 3 The Product Catalog . . . . . . . . . . . . . . . . . . . . . . . . 55 7 The Shopping Cart . . . . . . . . . . . . . . . . . . . . . . . . . 56 9 Recording the Orders