
When designing a website, it is sometimes necessary to redirect the user to another URL that are trying to access. This power can be performed using HTTP redirect normally, however, sometimes simply do not apply or, if you want to do with PHP, for example:
1. If the page has been some maintenance and I want to redirect users to an error page.
2. As part of a condition if you want PHP to redirect to another page, you may want to check if the user is logged in everything and if not redirected to the prompt connection.
I'm sure many other reasons that escape me at the time to write about why you want to do.
Fortunately, PHP provides a way to allow Web designers to make the control. This is done by manipulating the head of a web page before it is expressed. URL forwarding alternative page to replace the file contents:
Please note that the production must be written in the browser (including HTML tags), makes this approach work, to be the sole or first produced in the archive. So if you want to use through as a test of conditional logic at the beginning of the file, for example:
PHP open
If (loggedin == true) (
Close PHP
A … HTML output can go here
PHP open
) Other (
header ( 'Location: href = "http: / / Www.yourURL.com "> http://www.yourURL.com ');
)
Close PHP
To view the code in this section Close OPEN correctly and PHP PHP tags are used instead of the real start and end tags in php? – To run the code, you need to be replaced end Labels front and right.
This technique is simple to control the flow control in a browser-based PHP applications. In general, if you ever want to redirect to another URL, you must use an HTTP redirect, redirection, but also the choice of PHP.
Configure Database in Dreamweaver, PHP MySQL