Results 1 to 4 of 4
  1. #1
    Join Date
    May 2003
    Posts
    25

    Unanswered: 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?

  2. #2
    Join Date
    Feb 2002
    Posts
    43

    Re: Redirect problem

    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.

  3. #3
    Join Date
    Oct 2003
    Location
    Slovakia
    Posts
    482

    Re: Redirect problem

    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.

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •