8.5. Redirecting to a Different Location8.5.1. ProblemYou want to automatically send a user to a new URL. For example, after successfully saving form data, you want to redirect a user to a page that confirms the data. 8.5.2. SolutionBefore any output is printed, use header( ) to send a Location header with the new URL:
8.5.3. DiscussionIf you want to pass variables to the new page, you can include them in the query string of the URL:
The URL that you are redirecting a user to is retrieved with GET. You can't redirect someone to retrieve a URL via POST. You can, however, send other headers along with the Location header. This is especially useful with the Window-target header, which indicates a particular named frame or window in which to load the new URL:
The redirect URL must include the protocol and hostname; it can't just be a pathname:
8.5.4. See AlsoDocumentation on header( ) at http://www.php.net/header.
Copyright © 2003 O'Reilly & Associates. All rights reserved. |
|