how to redirect from php page

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

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

how to redirect from php page

Postby 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?

Thanks

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

Postby 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...

||EDIT:
another way:

Code: Select all

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

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

meta headers

Postby 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

eg.

Code: Select all

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

Just include the above code into your

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

Postby 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.


Return to “PHP coding => General”

Who is online

Users browsing this forum: Google Feedfetcher and 2 guests