SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: header(

  1. #1
    SitePoint Zealot
    Join Date
    Jul 2000
    Posts
    132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey again guys.
    On my php advert sys, I am getting a weird error. Well, I think its weird, anyway!

    Right, what happens is, the php scripts won't redirect using the 'header ("Location: blah.php");' code.

    This is happening in a few of my scripts. For example, on a forgot password? script I have done, what I want is, if someone has forgotten their password, they follow the link to:
    forgotpw.php?forgot=1

    So, then, what I am doing with php, is saying that if the 'forgot=1' isn't present, they haven't followed a link, and so it redirects them back to the login page.

    The error I get is:



    Warning: Cannot add header information - headers already sent by (output started at C:/PROGRAMMING/eliter/advertsys/forgotpw.php:17) in C:/PROGRAMMING/eliter/advertsys/forgotpw.php on line 39

    I am getting this in more than one script..

    Anyone know what this could be?
    Cheers.
    -aJ

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    YOu cannot have any output above the header() call. That means if you are printing anything or you have blank spaces or html tags above your opening <? tag you will get this error.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    SitePoint Zealot
    Join Date
    Jul 2000
    Posts
    132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)


    } elseif (!$forgot) {

    header ("Location: $advertiserlogin");

    }

    so is there anything wrong with that then?

    (I do have a few openings and closings of <?php ?> above that though)
    cheers
    ,aj

  4. #4
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes you cannot have those any opening and closings of <? ?> above that so I assume you have something like
    <html>
    <head>
    </head>
    <body>
    <?
    } elseif (!$forgot) {

    header ("Location: $advertiserlogin");

    }

    ?>

    YOU cannot have any ouput above the header() call This will cause your error.

    As will
    <?
    //Some code
    ?>

    <?
    } elseif (!$forgot) {

    header ("Location: $advertiserlogin");

    }
    ?>
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  5. #5
    SitePoint Zealot
    Join Date
    Jul 2000
    Posts
    132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ah, i see.
    Thanks v. much.


Bookmarks

Posting Permissions

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