Chapter 9. Moving Information from One Web Page to the Next

In This Chapter

  • Moving your user from one page to the next

  • Moving information from one page to the next

  • Adding information to a URL

  • Taking a look at cookies

  • Using hidden form fields

  • Discovering PHP sessions

Most Web sites consist of more than one Web page. This includes the static Web pages that you may have developed in the past. With static Web pages, users click a link in one Web page, and a new Web page appears in their browser. When users move from page to page this way, no information is transferred from the first page to the second. Each new page that is sent to the user's browser is independent of any other pages the user may have seen previously.

With dynamic Web pages, you may need to transfer information from one page to the next. If you're an advanced HTML developer, you may have experience with limited methods for transferring information from one page to the next using HTML forms and CGI (Common Gateway Interface) or cookies. However, PHP is a more powerful method for passing information from Web page to Web page.

Moving Your User from One Page to Another

When using only HTML, you provide links so that a visitor can go from one page to another in your Web site. When using PHP, you have three options for moving your user from one page to the next:

  • Links: You can echo the HTML tags that display a link. The general format of an HTML statement that displays a link is

    <a href="newpage.php">Text user sees as a link</a>

    When ...

Get PHP and MySQL® For Dummies®, 4th Edition 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.