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

how to redirect from php page

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

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?

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

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

another way:
Code: Select all
if ($password == "example") include("rightpw.php");
else include("falsepw.php");
New php-forum User
New php-forum User
Posts: 26
Joined: Sat Aug 30, 2003 9:04 am

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

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

Just include the above code into your
User avatar
php-forum Super User
php-forum Super User
Posts: 1280
Joined: Sat Mar 22, 2003 9:42 am
Location: Mumbai, India

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.
New php-forum User
New php-forum User
Posts: 193
Joined: Sat Mar 29, 2003 11:57 pm
Location: Auckland, New Zealand

Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot] and 4 guests

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