Warning: Cannot modify headerm msg

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nasse
    New Member
    • May 2007
    • 12

    Warning: Cannot modify headerm msg

    I am getting the following error msg whenever I try to login. I tried to turn my output_bufferin g = On in my php.ini but is not working for me. Would you please help me:

    Warning: Cannot modify header information - headers already sent by (output started at C:\Inetpub ........login\i nclude\header.p hp:9) in C:\Inetpub\vhos ts\.....\httpdo cs\login\login. php on line 23

    And here is the content of the header.php page which is included in all my pages:

    [code=html]
    <?php session_start() ;?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" lang="en"
    <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <meta http-equiv="cache-control" content="no-cache" />
    <meta http-equiv="expires" content="3600" /
    <meta name="revisit-after" content="2 days" />
    <meta name="robots" content="index, follow" />
    <meta name="publisher " content="<?php echo $publisher;?>" />
    <meta name="copyright " content="<?php echo $copyRight; ?>" />
    <meta name="author" content="<?php echo $author; ?>" />
    <meta name="distribut ion" content="global " />
    <meta name="descripti on" content="<?php echo $siteDescriptio n; ?>" />
    <meta name="keywords" content="<?php echo $keyWords; ?>" />
    <link rel="stylesheet " type="text/css" media="screen,p rojection,print " href="./css/setup.css" />
    <link rel="stylesheet " type="text/css" media="screen,p rojection,print " href="./css/text.css" />
    <link rel="icon" type="image/x-icon" href="./img/favicon.ico" />
    <title><?php echo $pageTitle; ?></title>
    </head>

    <!-- Global IE fix to avoid layout crash when single word size wider than column width -->
    <!--[if IE]><style type="text/css"> body {word-wrap: break-word;}</style><![endif]-->
    <body>
    <!-- Main Page Container -->
    <div class="page-container">

    <!-- For alternative headers START PASTE here -->

    <!-- A. HEADER -->
    <div class="header">

    <!-- A.1 HEADER TOP -->
    <div class="header-top">

    <!-- Sitelogo and sitename -->
    <a class="sitelogo " href="" title="Go to Start page"></a>
    <div class="sitename ">
    <h1><a href="index.php " title="Go to Start page"><?php echo $_SERVER[HTTP_HOST];?><span style="font-weight:normal;f ont-size:50%;">&nbs p;<?php echo $softwareVersio n; ?></span></a></h1>
    <h2><?php echo $softwareVersio n; ?><?php echo $companySlogan; ?></h2>
    </div>

    <!-- Navigation Level 0 -->
    <div class="nav0">

    </div>

    <!-- Navigation Level 1 -->
    <div class="nav1">
    <ul>
    <li><a href="<?php echo $nav11; ?>.php" title="Go to Start page"><?php echo $nav11; ?></a></li>
    <li><a href="<?php echo $nav12; ?>.php" title="Get to know who we are"><?php echo $nav12; ?></a></li>
    <li><a href="<?php echo $nav13; ?>.php" title="Get in touch with us"><?php echo $nav13; ?></a></li>

    <?php
    if(!empty($_SES SION[user_id]))
    {
    ?>
    <dt><a href="logout.ph p">Logout</a></dt>

    <?php
    }
    else
    {
    ?>
    <li><a href="login.php " title="Login to manage your account securely">Login </a></li>
    <?php
    }
    ?>

    </ul>
    </div>
    </div>

    <!-- A.2 HEADER MIDDLE -->
    <div class="header-middle">

    <!-- Site message -->
    <div class="sitemess age">
    <h1><?php echo $siteMessage1; ?></h1>
    <h2><?php echo $siteMessage2; ?><br /> <?php echo $siteMessage3; ?><br /> <?php echo $siteMessage4; ?></h2>
    <h3><a href="#"><?php echo $moreDetails; ?></a></h3>
    </div>
    </div>
    [/code]

    [Please use CODE tags when posting source code. Thanks! --pbmods]
    Last edited by pbmods; May 30 '07, 11:33 PM. Reason: Added code tags.
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya, nasse. Welcome to TSDN!

    You can't use the header function after you output something, which header.php does in spades.

    To get this to work, you need to move your header() statement above the line where you include header.php.

    E.g.:

    [code=php]
    header('Content-type: wacky/doodle');
    include('header .php');
    [/code]

    Comment

    • nasse
      New Member
      • May 2007
      • 12

      #3
      Originally posted by pbmods
      Heya, nasse. Welcome to TSDN!

      You can't use the header function after you output something, which header.php does in spades.

      To get this to work, you need to move your header() statement above the line where you include header.php.

      E.g.:

      [code=php]
      header('Content-type: wacky/doodle');
      include('header .php');
      [/code]
      Thank you very much for the prompt response and the effort to resolve the problem.

      But the header() statement is also included in this header.php file and is at the top of the header.php:

      Comment

      • pbmods
        Recognized Expert Expert
        • Apr 2007
        • 5821

        #4
        Originally posted by nasse
        But the header() statement is also included in this header.php file and is at the top of the header.php:
        I don't see it in your code, and the warning you're getting is complaining about C:\Inetpub\vhos ts\.....\httpdo cs\login\login. php on line 23.

        Comment

        • nasse
          New Member
          • May 2007
          • 12

          #5
          Thank you very much. I did per your advise and finally worked out for me. Thx once more.

          Comment

          • pbmods
            Recognized Expert Expert
            • Apr 2007
            • 5821

            #6
            You're welcome.

            Good luck with your project! If you get stuck, just post back, and we'll getcha going again ~_^

            Comment

            Working...