If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > PHP > Redirect problem

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-28-03, 11:30
ab8140 ab8140 is offline
Registered User
 
Join Date: May 2003
Posts: 25
Redirect problem

Ok, I have a logout page where I would like to redirect users back to the login page. I use this command

header("Location:login.php");

but I recieve an error on the page that says:

Warning: Cannot modify header information - headers already sent by (output started at /home/stu/ab8140/public_html/onboard/check_login.php:66) in /home/stu/ab8140/public_html/onboard/logout.php

Any suggestions on why this is occuring?
Reply With Quote
  #2 (permalink)  
Old 11-03-03, 12:53
cmptrguru7 cmptrguru7 is offline
Registered User
 
Join Date: Feb 2002
Posts: 43
Re: Redirect problem

Quote:
Originally posted by ab8140
Ok, I have a logout page where I would like to redirect users back to the login page. I use this command

header("Location:login.php");

but I recieve an error on the page that says:

Warning: Cannot modify header information - headers already sent by (output started at /home/stu/ab8140/public_html/onboard/check_login.php:66) in /home/stu/ab8140/public_html/onboard/logout.php

Any suggestions on why this is occuring?
Try using the follwing statement:

echo("<HEAD><META HTTP-EQUIV=Refresh CONTENT='3; URL=$PHP_SELF'</HEAD>");

content=3 is how long you want to wait before the redirection
url = is the page you want to redirect to.

This does not work in all browsers, but has worked for me. The problem you are having is that I do not think you can use the header function if you have displayed anything on the screen already.
Reply With Quote
  #3 (permalink)  
Old 12-07-03, 18:00
ika ika is offline
Registered User
 
Join Date: Oct 2003
Location: Slovakia
Posts: 482
Re: Redirect problem

Quote:
Originally posted by ab8140
Ok, I have a logout page where I would like to redirect users back to the login page. I use this command

header("Location:login.php");

but I recieve an error on the page that says:

Warning: Cannot modify header information - headers already sent by (output started at /home/stu/ab8140/public_html/onboard/check_login.php:66) in /home/stu/ab8140/public_html/onboard/logout.php

Any suggestions on why this is occuring?
Your problem is you are using echo function before header function.
Reply With Quote
  #4 (permalink)  
Old 12-24-03, 20:23
WhSox21 WhSox21 is offline
Registered User
 
Join Date: Dec 2003
Posts: 31
Any output sent to the browser before that will give you that error. If you just hit enter one time before the php tag then that will give you the error. Or output any code using php.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On