Skip to Content
Web Database Applications with PHP, and MySQL
book

Web Database Applications with PHP, and MySQL

by Hugh E. Williams, David Lane
March 2002
Intermediate to advanced
592 pages
15h 52m
English
O'Reilly Media, Inc.
Content preview from Web Database Applications with PHP, and MySQL

Managing Redirection

The cart.5 script shown in Example 11-6 is a central point that manages redirection to other scripts in the winestore. All pages that have more than one button request this script using the action attribute of the <form> element. The script processes the requests, determines from the GET method attributes which script should be requested next, and then redirects the browser to that script.

For example, if the user clicks the Empty Cart button on any page, the following URL is requested:

http://localhost/example.cart.5.php?empty=Empty+Cart

The cart.5 script is then processed, the following if test is found to be true, and the script redirects to the cart.4 script:

// Did they want to empty the cart?
if (!empty($parameters["empty"]))
{
   // Redirect the browser to the empty page
   // using the HTTP response header "Location:"
   header("Location: example.cart.4.php");
   exit;
}

When redirecting to some scripts, the redirection also passes on the entire QUERY_STRING—the query string is stored in the PHP environment variable $QUERY_STRING—as a GET method parameter. In addition, a session variable, referer, is registered in selected cases so that in later processing the script can redirect to the original calling page.

As discussed in Chapter 10, there are several other possible approaches for managing requests for different scripts throughout an application. An alternative to the approach is to add each button to the HTML page as a separate <form> element with its own ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Web Database Applications with PHP and MySQL, 2nd Edition

Web Database Applications with PHP and MySQL, 2nd Edition

Hugh E. Williams, David Lane
Mastering PHP 7

Mastering PHP 7

Branko Ajzele

Publisher Resources

ISBN: 0596000413Catalog PageErrata