SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2003
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    allowing header() anywhere???

    how do you allow using header() anywhere in your program? i made a program for a friend, and he's getting 'headers already sent' warnings.

  2. #2
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    output buffering
    Mike
    It's not who I am underneath, but what I do that defines me.

  3. #3
    "Of" != "Have" bronze trophy Jeff Lange's Avatar
    Join Date
    Jan 2003
    Location
    Calgary, Canada
    Posts
    2,063
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Who walks the stairs without a care
    It shoots so high in the sky.
    Bounce up and down just like a clown.
    Everyone knows its Slinky.

  4. #4
    SitePoint Enthusiast
    Join Date
    Jan 2003
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by cyborg from dh
    So i just place this at the top of my files?

  5. #5
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes, before any output is sent; or redesign your scripts so that they don't send output before headers.
    - Matt ** Ignore old signature for now... **
    Dr.BB - Highly optimized to be 2-3x faster than the "Big 3."
    "Do not enclose numeric values in quotes -- that is very non-standard and will only work on MySQL." - MattR

  6. #6
    "Of" != "Have" bronze trophy Jeff Lange's Avatar
    Join Date
    Jan 2003
    Location
    Calgary, Canada
    Posts
    2,063
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeah either or

    (I use ob_start() a lot in my template system though, to capture output for later usage )
    Who walks the stairs without a care
    It shoots so high in the sky.
    Bounce up and down just like a clown.
    Everyone knows its Slinky.

  7. #7
    SitePoint Enthusiast
    Join Date
    Jan 2003
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by cyborg from dh
    yeah either or [img]images/smilies/wink.gif[/img]

    (I use ob_start() a lot in my template system though, to capture output for later usage [img]images/smilies/wink.gif[/img])
    Here is the script that causes errors. Is it because <html><body> is above the script???

    PHP Code:
    <html>
    <body>
    <?php
    include("lib/config.php");
    include(
    "lib/db_connect.php");
    include(
    "lib/chk_ip.php");
    if(isset(
    $_POST['do_login'])) {
     
    $username $_POST['username'];
     
    $password md5($_POST['password']); 
     
    $query "SELECT * FROM users WHERE username = '$username' AND password = '$password' AND permissions = '1' LIMIT 1";
     
    $result mysql_query($query);
     if(
    mysql_num_rows($result) != 1) {
      
    header("location:login.php?error=Invalid");
     } else {
      
    setcookie("admin",1,time()+(60*30));
      
    setcookie("auth",$username,time()+(60*30));
      
    header("location:admin.php");
     }
    }
    ?>

  8. #8
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Yes, that is why.
    Mike
    It's not who I am underneath, but what I do that defines me.


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
  •