how to redirect from php page

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Post Reply
New php-forum User
New php-forum User
Posts: 29
Joined: Fri Jun 27, 2003 10:05 pm

how to redirect from php page

Post by DigitalRice » Sun Sep 14, 2003 8:43 am

hi, is there a way to redirect to a different page from a php page? for example. i want a user after log into my website, check the user password and so on, if it correct, i want to redirect to a different correct page, if the user and password is wrong, then i redirect to error page and so on. is there a way to redirect a page or load other page from a php page without using <meta > tag?


New php-forum User
New php-forum User
Posts: 26
Joined: Sat Aug 30, 2003 9:04 am

Post by toweter » Sun Sep 14, 2003 9:06 am

yes, that's possible.

Code: Select all

header("Location: script2.php?password=xxxxx");

that will not work if you already have sent a header information or some (echo/print) - text...

another way:

Code: Select all

if ($password == "example") include("rightpw.php");
else include("falsepw.php");

User avatar
php-forum Super User
php-forum Super User
Posts: 1280
Joined: Sat Mar 22, 2003 9:42 am
Location: Mumbai, India

meta headers

Post by ruturajv » Sun Sep 14, 2003 9:20 pm

Another way to redirect the user is to use a meta header
you can see a message something like

You are bein redirected, if your browser does not support meta redirection then click here


Code: Select all

echo ("<meta htt-equiv='refresh' content='3; newpage.php'>");

Just include the above code into your

New php-forum User
New php-forum User
Posts: 193
Joined: Sat Mar 29, 2003 11:57 pm
Location: Auckland, New Zealand

Post by Joel » Sun Sep 14, 2003 11:19 pm

Remember on the file where the correct password has taken them - To check they are authorised to view that page.

Post Reply

Who is online

Users browsing this forum: No registered users and 15 guests