SitePoint Sponsor

User Tag List

Results 1 to 14 of 14
  1. #1
    is craving 'the potato' slayerment's Avatar
    Join Date
    Nov 2002
    Location
    Scottsdale, Arizona, USA
    Posts
    603
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question: Headers and Sessions problem

    Ok it turns out I'm still having a problem. I know its been posted many times, but I can't figure this out.

    I get this error message when i got to my 'Update Profile' page:

    Warning: Cannot send session cache limiter - headers already sent (output started at /usr/www/users/emmarose/pioneer/extranet/client_update.php:1) in /usr/www/users/emmarose/pioneer/extranet/accesscontrol.php on line 2

    See for yourself http://www.pioneergraphics.com/extranet
    User: test
    Pass: test

    It gets the information okay, but displays that message at the top. I have included my code below. If possible, is there a way to hide the warning message?

    accesscontrol.php
    PHP Code:
    <?php
    session_start
    ();
    include(
    "common.php" );
    include(
    "db.php" );
    $uid = isset($_POST['uid']) ? $_POST['uid'] : $_SESSION['uid'];
    $pwd = isset($_POST['pwd']) ? $_POST['pwd'] : $_SESSION['pwd'];
    if(
    $uid == "" || $pwd == "" ){
    ?>
    <html>
    <head>
    <title>Pioneer Graphics - Extranet</title>
    <link href="../style.css" rel="stylesheet" type="text/css">
    </head>
    <body bgcolor="44697F" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
    <table width="584" border="0" align="right" cellpadding="5" cellspacing="0">
    <tr>
    <td><table width="100%" border="0" cellpadding="2" cellspacing="0" bgcolor="9EB5C3">
    <tr> 
    <td><div align="left" class="textb"> 
    <table width="100%" border="0" cellpadding="5" cellspacing="0" bgcolor="174560">
    <tr> 
    <td><div align="center" class="text3b">+--- User Authentication 
    Required_</div></td>
    </tr>
    </table>
    </div></td>
    </tr>
    <tr> 
    <td class="text2b"><table width="100%" border="2" cellpadding="2" cellspacing="1" bordercolor="9EB5C3" bgcolor="7C9CB0">
    <tr>
    <td><form name="form1" method="post" action="<?=$PHP_SELF?>">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr> 
    <td colspan="2" class="text2b">You must log in to access 
    this area of the site.</td>
    </tr>
    <tr> 
    <td width="50%" class="text2">Username: 
    <input name="uid" type="text" class="textbox3" id="uid" size="20"></td>
    <td width="50%"><span class="text2">Password:</span> <input name="pwd" type="password" class="textbox3" id="pwd" size="20"></td>
    </tr>
    <tr> 
    <td colspan="2"><div align="center"><br>
    <input name="Submit" type="submit" class="button2" value="Login">
    </div></td>
    </tr>
    </table>
    </form></td>
    </tr>
    </table></td>
    </tr>
    </table></td>
    </tr>
    </table>
    </body>
    </html>
    <?
    exit;
    }
    $_SESSION['uid'] = $uid;
    $_SESSION['pwd'] = $pwd;
    dbConnect("emmarose_client" ); 
    $sql "SELECT * FROM clients WHERE 
    userid = '
    $uid' AND password = '$pwd'"
    $result mysql_query($sql);
    if (
    mysql_num_rows($result) == 0) {
    unset(
    $_SESSION['uid']);
    unset(
    $_SESSION['pwd']);
    ?>
    <html>
    <head>
    <link href="../style.css" rel="stylesheet" type="text/css">
    </head>
    <body bgcolor="44697F" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
    <table width="460" border="0" cellspacing="0" cellpadding="5">
    <tr>
    <td><table width="100%" border="0" cellpadding="2" cellspacing="0" bgcolor="9EB5C3">
    <tr> 
    <td><div align="left" class="textb"> 
    <table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="174560">
    <tr> 
    <td><div align="center" class="text3b">Error - No Match Found</div></td>
    </tr>
    </table>
    </div></td>
    </tr>
    <tr> 
    <td class="text2b"><div align="center"> 
    <p class="menu2">Your username and password were not found on our 
    database.<br>
    <br>
    <a href="<?=$PHP_SELF?>" class="menu2">Click here to try again</a></p>
    </div></td>
    </tr>
    </table></td>
    </tr>
    </table>
    </body>
    </html>
    <?php 
    exit; 
    }
    $first mysql_result($result,0,"firstname" );
    $last mysql_result($result,0,"lastname" );
    ?>
    client_update.php
    PHP Code:
    <?
    include("accesscontrol.php" );
    ?>
    <html>
    <head>
    <link href="../style.css" rel="stylesheet" type="text/css">
    </head>
    <body bgcolor="44697F" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
    <table width="584" border="0" align="right" cellpadding="5" cellspacing="0">
    <tr> 
    <td><table width="100%" border="0" cellpadding="2" cellspacing="0" bgcolor="9EB5C3">
    <tr> 
    <td><div align="left" class="textb"> 
    <table width="100%" border="0" cellpadding="5" cellspacing="0" bgcolor="174560">
    <tr> 
    <td><div align="center" class="text3b">+--- Profile Update for 
    User <?=$first?> <?=$last?>_</div></td>
    </tr>
    </table>
    </div></td>
    </tr>
    <tr> 
    <td class="text2b"><table width="100%" border="2" cellpadding="2" cellspacing="1" bordercolor="9EB5C3" bgcolor="7C9CB0">
    <tr> 
    <td><form name="form1" method="post" action="client_mail.php">
    <span class="text2b"> Please add any changes you would like 
    to make.</span><br>
    <table width="100%" border="0" cellpadding="2" cellspacing="0" class="text2">
    <tr> 
    <td width="15%">First Name:</td>
    <td width="35%"><input name="textfield" type="text" class="textbox3"></td>
    <td width="15%">Last Name:</td>
    <td width="35%"><input name="textfield2" type="text" class="textbox3"></td>
    </tr>
    <tr> 
    <td>Company Name:</td>
    <td><input name="textfield3" type="text" class="textbox3"></td>
    <td>Position:</td>
    <td><input name="textfield22" type="text" class="textbox3"></td>
    </tr>
    <tr> 
    <td>Address:</td>
    <td><input name="textfield4" type="text" class="textbox3"></td>
    <td>City:</td>
    <td><input name="textfield23" type="text" class="textbox3"></td>
    </tr>
    <tr> 
    <td>State:</td>
    <td><input name="textfield5" type="text" class="textbox3"></td>
    <td>Zip:</td>
    <td><input name="textfield24" type="text" class="textbox3"></td>
    </tr>
    <tr> 
    <td>Country:</td>
    <td><input name="textfield6" type="text" class="textbox3"></td>
    <td>Phone:</td>
    <td><input name="textfield25" type="text" class="textbox3"></td>
    </tr>
    <tr> 
    <td>Fax:</td>
    <td><input name="textfield7" type="text" class="textbox3"></td>
    <td>Email:</td>
    <td><input name="textfield26" type="text" class="textbox3"></td>
    </tr>
    <tr> 
    <td>New Password:</td>
    <td><input name="textfield72" type="text" class="textbox3"></td>
    <td>Confrim Password:</td>
    <td><input name="textfield73" type="text" class="textbox3"></td>
    </tr>
    <tr> 
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    </table>
    </form></td>
    </tr>
    </table></td>
    </tr>
    </table></td>
    </tr>
    </table>
    </body>
    </html>
    Any help would be greatly appreciated guys .
    Thanks much
    Last edited by slayerment; Oct 11, 2003 at 21:25.

  2. #2
    is craving 'the potato' slayerment's Avatar
    Join Date
    Nov 2002
    Location
    Scottsdale, Arizona, USA
    Posts
    603
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    *bump*

    Sorry, It turns out that I'm getting this error again, so I edited my first post. Any help would be great. Thanks.

  3. #3
    $postcount++; koomann's Avatar
    Join Date
    Feb 2003
    Location
    Posts
    428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The test/test user/password combo seemed to have worked perfectly fine for me.

    Guess ya got it =]

    [EDIT]Gah, I finally clicked the Update Profile link. I really have to stop staying up this late.

    As for your problem, well, I'm still trying =P

  4. #4
    SitePoint Enthusiast Deo's Avatar
    Join Date
    Oct 2003
    Location
    Washington, USA
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try removing all spaces and new lines at the end of the files. This has been known to throw that error.

  5. #5
    is craving 'the potato' slayerment's Avatar
    Join Date
    Nov 2002
    Location
    Scottsdale, Arizona, USA
    Posts
    603
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have no spaces or anything before I start a session... Still not working . Would using frames have any effect maybe?

  6. #6
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nope

    What made you think that FRAMEs were the problem when it's server-side technology you're using huh ?

    Doubtful but try this slight alteration ?

    PHP Code:
    session_start();
    $uid = isset($_POST['uid']) ? $_POST['uid'] : $_SESSION['uid'];
    $pwd = isset($_POST['pwd']) ? $_POST['pwd'] : $_SESSION['pwd'];


    include(
    "common.php" );
    include(
    "db.php" );

    if(
    $uid == "" || $pwd == "" ){
    ?>
    .
    ... 
    Also try removing that
    PHP Code:
    exit; 
    to see that it isn't effecting the page...

  7. #7
    is craving 'the potato' slayerment's Avatar
    Join Date
    Nov 2002
    Location
    Scottsdale, Arizona, USA
    Posts
    603
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Still nothing. I thought frames because both my pages include accesscontrol.php and I thought maybe that would pose a threat. I sit corrected . I'm totally stumped on this. This looks like it should be working

  8. #8
    SitePoint Addict shad0w's Avatar
    Join Date
    Aug 2003
    Location
    PA
    Posts
    239
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try getting rid of all the extra spaces before all your closing parentheses. Like right here:
    PHP Code:
    <?
    include("accesscontrol.php" );
    ?>

  9. #9
    is craving 'the potato' slayerment's Avatar
    Join Date
    Nov 2002
    Location
    Scottsdale, Arizona, USA
    Posts
    603
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    On my actual script those aren't there... I dont know why they showed up when I pasted it.

  10. #10
    SitePoint Addict shad0w's Avatar
    Join Date
    Aug 2003
    Location
    PA
    Posts
    239
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, since nothing has worked so far, I'd look into output buffering, that should get rid of any "header can't be sent" errors.

  11. #11
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Instead of INCLUDing the file 'accesscontrol.php' inside the file 'client_update.php' as you have, have the file 'accesscontrol.php' redirect to 'client_update.php' instead ?

    ie

    PHP Code:
    .
    .
    $first mysql_result($result,0,"firstname" );
    $last mysql_result($result,0,"lastname" );
    $url='client_update.php?first='.$first.'&last='.$last;
    header('location:'.$url); 
    Then use

    PHP Code:
    +--- Profile Update for 
    User <?=$_GET['first'?> <?=$_GET['last'?>_</div></td>
    To see if that helps you ?

  12. #12
    is craving 'the potato' slayerment's Avatar
    Join Date
    Nov 2002
    Location
    Scottsdale, Arizona, USA
    Posts
    603
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey guys,
    I put @ in front of my session start and now its not displaying that warning and its working:
    PHP Code:
    <?
    @session_start();
    $uid = isset($_POST['uid']) ? $_POST['uid'] : $_SESSION['uid'];
    $pwd = isset($_POST['pwd']) ? $_POST['pwd'] : $_SESSION['pwd'];
    include(
    "common.php");
    include(
    "db.php" );
    if(
    $uid == "" || $pwd == ""){
    ?>
    Is there anything wrong with fixing my problem this way or is it kind of a hack job?
    Thanks for all the help guys .

  13. #13
    SitePoint Enthusiast Deo's Avatar
    Join Date
    Oct 2003
    Location
    Washington, USA
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well the @ just supresses the actual error. Just make sure that the session is still active. I would definitly try to get rid of the errors before supressing them. Sometimes it can come back to you later on down the code.
    Mark
    www.MySpaceWatcher.com
    Tracking & Statistics For MySpace.com Users

  14. #14
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    its not displaying that warning and its working
    Suggests to me that there is an underlying problem that isn't going to go away long term ?

    Using @ solves this problem for the time being but that's not to say this issue isn't going to come back to haunt you later


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
  •