Click to See Complete Forum and Search --> : redirect to page using PHP


sgalmeida
01-10-2004, 01:02 PM
Greetings

how can I redirect my page to another using PHP? Using Javascript I can do this using the code window.location='mypage.php'. How can I do this using PHP??

Thank you very much

Sérgio

pyro
01-10-2004, 01:16 PM
You can find out in the manuals section on headers (http://us4.php.net/manual/en/function.header.php). Just remember, headers must be set before any content is sent to the browser.

dreamcatcher
01-11-2004, 09:28 AM
Or you can use a meta refresh:

echo "<meta http-equiv=\"refresh\" content=\"3;URL=blah.php\">\n";

I usually use it in a function:

function redirect()

{

echo "<meta http-equiv=\"refresh\" content=\"3;URL=blah.php\">\n";
echo "Please wait.....";
exit;

}


Call the function at the end of your code. The '3' in the code is 3 seconds.

Hope that helps too. :)

pyro
01-11-2004, 09:59 AM
You should keep in mind, however, that this method can be disabled on the client end, and can't truly be relied on.