SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Thread: headers?

  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2005
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    headers?

    error recieved:

    Code:
    userpassSUCCESS!
    Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/amoebic/public_html/pass.php:6) in /home/amoebic/public_html/pass.php on line 22
    
    Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/amoebic/public_html/pass.php:6) in /home/amoebic/public_html/pass.php on line 22
    my code(pass.php):
    Code:
    <?php
    $username = $_GET['user'];
    $password = $_GET['pass'];
    echo($username);
    echo($password);
    if(($username != 'user') || ($password != 'pass'))
    {
    	header('WWW-Authenticate: Basic realm="Private" ');
    	header('HTTP/1.0 401 Unauthorized');
    	echo("Authorization required.");
    	exit;
    }
    else
    {
    	$permission = "yes";
    	echo("SUCCESS!");
    	session_start();
    	session_register("permission");   
    	session_register("username");
    }
    ?>

  2. #2
    Sell crazy someplace else markl999's Avatar
    Join Date
    Aug 2003
    Location
    Manchester, UK
    Posts
    4,007
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You cannot have any output before a header. Make sure there's no output (even whitespace/newlines) before the <?php line in your above post.

  3. #3
    SitePoint Member
    Join Date
    Nov 2005
    Location
    Belgium
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What do you have in /home/amoebic/public_html/pass.php:6 ?

  4. #4
    SitePoint Enthusiast
    Join Date
    Aug 2005
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    oops sorry i posted the wrong set of code...

    check now.

  5. #5
    SitePoint Zealot musher's Avatar
    Join Date
    Nov 2005
    Location
    Hull, England
    Posts
    161
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could either turn on Output Buffering or make sure there's no whitespace above your
    PHP Code:
    <?php
    tag.

  6. #6
    SitePoint Enthusiast
    Join Date
    Aug 2005
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    can you guys check the new code?

  7. #7
    SitePoint Addict
    Join Date
    Apr 2005
    Location
    San Diego, CA
    Posts
    205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can't do a session_start() after outputting any text (i.e. echo("SUCCESS!").
    I study speed waiting. I can wait an entire hour in 10 minutes.


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
  •