redirect to a new Url?

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

mnicolas80
New php-forum User
New php-forum User
Posts: 3
Joined: Fri Nov 29, 2002 8:44 am

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 (........).

serg_dz
New php-forum User
New php-forum User
Posts: 13
Joined: Thu Oct 10, 2002 10:37 pm
Location: Ukraine

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

Use something like this:

header("Location: admin_menu.php?uid=$uid&sid=$sid");

User avatar
ppera
New php-forum User
New php-forum User
Posts: 11
Joined: Thu Jan 09, 2003 2:11 pm

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.


Return to “PHP coding => General”

Who is online

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