Chapter 2. Making Information Available on Multiple Web Pages

In This Chapter

  • Moving information from one page to the next

  • Adding information to a URL

  • Taking a look at cookies

  • Discovering PHP sessions

The simplest Web applications collect information from users in HTML forms and then use the information by displaying it, storing it, or using it in conditional statements. However, many dynamic Web applications are more complex than this. For example, a shopping cart must collect different types of information; display this information; keep track of what users have ordered; calculate prices, taxes, and shipping; charge credit cards; and perform other tasks. Such complex applications consist of several scripts that share information.

However, sharing information is not automatic for Web pages. HTML pages are stateless. That is, HTML pages are independent from one another. When a user clicks a link, the Web server sends a new page to the user's browser, but the browser doesn't know anything about the previous page. As far as the browser knows, this could be the first Web page ever in the history of the world. For static Web pages, where the user simply views a document, statelessness works fine. However, many dynamic Web applications need to pass information from Web page to Web page. For example, you may want to save a user's name and then display the name on another page.

This chapter discusses the basics of moving among Web pages and passing information between Web pages.

Get PHP & MySQL® Web Development All-in-One Desk Reference for Dummies® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.