Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

redirect to a new Url?

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

redirect to a new Url?

Postby mnicolas80 » Wed Jan 08, 2003 4:57 pm

How can i redirect a page to a new Url using PHP? For example in ASP is something like: response.redirect (........).
New php-forum User
New php-forum User
Posts: 3
Joined: Fri Nov 29, 2002 8:44 am

Postby serg_dz » Wed Jan 08, 2003 11:25 pm

Use something like this:

header("Location: admin_menu.php?uid=$uid&sid=$sid");
New php-forum User
New php-forum User
Posts: 13
Joined: Thu Oct 10, 2002 10:37 pm
Location: Ukraine

Postby ppera » Thu Jan 09, 2003 2:19 pm

Better way is this:
print"<META HTTP-EQUIV=\"Refresh\" CONTENT=\"0; URL=$page\">"; die;

This automatically redirects always, while header("Location.... works only if no html output is sent.

Statement die after prevents execution of further code if redirect is conditional.
User avatar
New php-forum User
New php-forum User
Posts: 11
Joined: Thu Jan 09, 2003 2:11 pm

Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.