"PHP" Scripting Language

Started by sivaji, Jan 11, 2008, 11:45 AM

Previous topic - Next topic

sivaji

Installation

Before you can start building your database-driven Web presence, you must first ensure that you have the right tools for the job. In this first chapter, I'll tell you where to obtain the two essential components you'll need: the PHP scripting language and the MySQL database management system. I'll step you through the setup procedures on Windows, Linux, and Mac OS X, and show you how to test that PHP is operational on your Web server.

Getting Started with MySQL

Although I'm sure you'll be anxious to get started building dynamic Web pages, I'll begin with an introduction to databases in general, and the MySQL relational database management system in particular. If you've never worked with a relational database before, this should definitely be an enlightening chapter that will whet your appetite for things to come! In the process, we'll build up a simple database to be used in later chapters.

Getting Started with PHP

Here's where the fun really starts. In this chapter, I'll introduce you to the PHP scripting language, which can easily be used to build dynamic Web pages that present up-to-the-moment information to your visitors. Readers with previous programming experience will probably be able to get away with a quick skim of this chapter, as I explain the essentials of the language from the ground up. This is a must-read chapter for beginners, however, as the rest of this book relies heavily on the basic concepts presented here.

Publishing MySQL Data on the Web

In this chapter we bring together PHP and MySQL, which you'll have seen separately in the previous chapters, to create some of your first databasedriven Web pages. We'll explore the basic techniques of using PHP to retrieve information from a database and display it on the Web in real time. I'll also
show you how to use PHP to create Web-based forms for adding new entries to, and modifying existing information in, a MySQL database on-the-fly.

Relational Database Design

Although we'll have worked with a very simple sample database in the previous chapters, most database-driven Websites require the storage of more complex forms of data than we'll have dealt with so far. Far too many database-driven Website designs are abandoned midstream, or are forced to start again from
the beginning, because of mistakes made early on, during the design of the database structure. In this critical chapter, I'll teach the essential principles of good database design, emphasizing the importance of data normalization.

If you don't know what that means, then this is definitely an important chapter for you to read!

A Content Management System

In many ways the climax of the book, this chapter is the big payoff for all you frustrated site builders who are tired of updating hundreds of pages whenever you need to make a change to a site's design. I'll walk you through the code for a basic content management system that allows you to manage a database of jokes, their categories, and their authors. A system like this can be used to manage simple content on your Website; just a few modifications, and you'll have a Web administration system that will have your content providers submitting content for publication on your site in no time—all without having to know a shred of HTML!

Content Formatting and Submission

Just because you're implementing a nice, easy tool to allow site administrators to add content to your site without their knowing HTML, doesn't mean you What's In This Book have to restrict that content to plain, unformatted text. In this chapter, I'll show you some neat tweaks you can make to the page that displays the contents of your database—tweaks that allow it to incorporate simple formatting such as bold or italicized text, among other things. I'll also show you a simple way safely to make a content submission form directly available to your content providers, so that they can submit new content directly into your system for publication, pending an administrator's approval.

MySQL Administration

While MySQL is a good, simple database solution for those who don't need many frills, it does have some complexities of its own that you'll need to understand if you're going to rely on a MySQL database to store your content. In this section, I'll teach you how to perform backups of, and manage access to, your MySQL database. In addition to a couple of inside tricks (like what to do if you forget your MySQL password), I'll explain how to repair a MySQL database that has become damaged in a server crash.

Advanced SQL Queries

In Relational Database Design we saw what was involved in modelling complex relationships between pieces of information in a relational database like MySQL. Although the theory was quite sound, putting these concepts into practice requires that you learn a few more tricks of Structured Query Language. In this chapter, I'll cover some of the more advanced features of this language to get you juggling complex data like a pro.

Binary Data

Some of the most interesting applications of database-driven Web design include some juggling of binary files. Online file storage services like the nowdefunct iDrive are prime examples, but even a system as simple as a personal photo gallery can benefit from storing binary files (e.g. pictures) in a database for retrieval and management on the fly. In this chapter, I'll demonstrate how to speed up your Website by creating static copies of dynamic pages as regular intervals—using PHP, of course! With these basic file-juggling skills in hand, we'll go on to develop a simple online file storage and viewing system and learn the ins and outs of working with binary data in MySQL.

Cookies and Sessions in PHP

One of the most hyped new features in PHP 4.0 was built-in support for sessions. But what are sessions? How are they related to cookies, a long-suffering technology for preserving stored data on the Web? What makes persistent data so important in current ecommerce systems and other Web applications?
This chapter answers all those questions by explaining how PHP supports both cookies and sessions, and exploring the link between the two. At the end of this chapter, we'll develop a simple shopping cart system to demonstrate their use.

Structured PHP Programming

Techniques to better structure your code are useful in all but the simplest of PHP projects. The PHP language offers many facilities to help you do this, and in this chapter, I'll explore some of the simple techniques that exist to keep your code manageable and maintainable. You'll learn to use include files to avoid having to write the same code more than once when it's needed by many pages of your site; I'll show you how to write your own functions to extend the built-in capabilities of PHP and to streamline the code that appears within your Web pages; we'll also dabble in the art of defining constants that control aspects of your Web applications' functionality. We'll then put all these pieces together to build an access control system for your Website. Its sophisticated structure will ensure that it can be used and reused on just about any site you decide to build.
Am now @ Chennai