Chapter 3. PHP and XHTML Forms
In This Chapter
Understanding the relationship between XHTML and PHP
Formatting date and time information
Creating XHTML forms designed to work with PHP
Retrieving data from your XHTML forms
Working with XHTML form elements
PHP is almost never used on its own. PHP is usually used in tight conjunction with XHTML. Many languages have features for creating input forms and user interfaces, but with PHP, the entire user experience is based on XHTML. The user never really sees any PHP. Most of the input to PHP programs comes from XHTML forms, and the output of a PHP program is an XHTML page.
In this chapter, you discover how to integrate PHP and XHTML. You explore how PHP code is embedded into XHTML pages, how XHTML forms can be written so they will send information to a PHP program, how to write a PHP program to read that data, and how to send an XHTML response back to the user.
Exploring the Relationship between PHP and XHTML
PHP is a different language than XHTML, but they are very closely related. It may be best to think of PHP as an extension that allows you to do things you cannot do easily in XHTML. See Figure 3-1 for an example.
Figure 3.1. This program gives me the current date and time.
Every time you run
getTime.php, it generates the current date and time, and returns these values to the ...