By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,949 Members | 890 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,949 IT Pros & Developers. It's quick & easy.

Warning: Cannot modify headerm msg

P: 12
I am getting the following error msg whenever I try to login. I tried to turn my output_buffering = 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\include\header.php:9) in C:\Inetpub\vhosts\.....\httpdocs\login\login.php on line 23

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

Expand|Select|Wrap|Line Numbers
  1. <?php session_start();?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" lang="en"
  4. <head>
  5.   <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  6.   <meta http-equiv="cache-control" content="no-cache" />
  7.   <meta http-equiv="expires" content="3600" /  
  8.   <meta name="revisit-after" content="2 days" />
  9.   <meta name="robots" content="index,follow" />
  10.   <meta name="publisher" content="<?php echo $publisher;?>" />
  11.   <meta name="copyright" content="<?php echo $copyRight; ?>" />
  12.   <meta name="author" content="<?php echo $author; ?>" />
  13.   <meta name="distribution" content="global" />
  14.   <meta name="description" content="<?php echo $siteDescription; ?>" />
  15.   <meta name="keywords" content="<?php echo $keyWords; ?>" />
  16.   <link rel="stylesheet" type="text/css" media="screen,projection,print" href="./css/setup.css" />
  17.   <link rel="stylesheet" type="text/css" media="screen,projection,print" href="./css/text.css" />
  18.   <link rel="icon" type="image/x-icon" href="./img/favicon.ico" />
  19.   <title><?php echo $pageTitle; ?></title>
  20. </head>
  21.  
  22. <!-- Global IE fix to avoid layout crash when single word size wider than column width -->
  23. <!--[if IE]><style type="text/css"> body {word-wrap: break-word;}</style><![endif]-->
  24. <body>
  25.   <!-- Main Page Container -->
  26.   <div class="page-container">
  27.  
  28.    <!-- For alternative headers START PASTE here -->
  29.  
  30.     <!-- A. HEADER -->      
  31.     <div class="header">
  32.  
  33.       <!-- A.1 HEADER TOP -->
  34.       <div class="header-top">
  35.  
  36.         <!-- Sitelogo and sitename -->
  37.         <a class="sitelogo" href="" title="Go to Start page"></a>
  38.         <div class="sitename">
  39.         <h1><a href="index.php" title="Go to Start page"><?php echo $_SERVER[HTTP_HOST];?><span style="font-weight:normal;font-size:50%;">&nbsp;<?php echo $softwareVersion; ?></span></a></h1>
  40.           <h2><?php echo $softwareVersion; ?><?php echo $companySlogan; ?></h2>
  41.         </div>
  42.  
  43.         <!-- Navigation Level 0 -->
  44.         <div class="nav0">
  45.  
  46.         </div>        
  47.  
  48.         <!-- Navigation Level 1 -->
  49.         <div class="nav1">
  50.           <ul>
  51.             <li><a href="<?php echo $nav11; ?>.php" title="Go to Start page"><?php echo $nav11; ?></a></li>
  52.             <li><a href="<?php echo $nav12; ?>.php" title="Get to know who we are"><?php echo $nav12; ?></a></li>
  53.             <li><a href="<?php echo $nav13; ?>.php" title="Get in touch with us"><?php echo $nav13; ?></a></li>
  54.  
  55. <?php
  56. if(!empty($_SESSION[user_id]))
  57. {
  58. ?>
  59.           <dt><a href="logout.php">Logout</a></dt>
  60.  
  61. <?php
  62. }
  63. else
  64. {
  65. ?>    
  66.             <li><a href="login.php" title="Login to manage your account securely">Login</a></li>
  67. <?php
  68. }
  69. ?>
  70.  
  71.           </ul>
  72.         </div>            
  73.       </div>
  74.  
  75.       <!-- A.2 HEADER MIDDLE -->
  76.       <div class="header-middle">
  77.  
  78.         <!-- Site message -->
  79.         <div class="sitemessage">
  80.           <h1><?php echo $siteMessage1; ?></h1>
  81.           <h2><?php echo $siteMessage2; ?><br /> <?php echo $siteMessage3; ?><br /> <?php echo $siteMessage4; ?></h2>
  82.           <h3><a href="#"><?php echo $moreDetails; ?></a></h3>
  83.         </div>   
  84.       </div>
  85.  
[Please use CODE tags when posting source code. Thanks! --pbmods]
May 30 '07 #1
Share this Question
Share on Google+
5 Replies


pbmods
Expert 5K+
P: 5,821
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.:

Expand|Select|Wrap|Line Numbers
  1. header('Content-type: wacky/doodle');
  2. include('header.php');
  3.  
May 30 '07 #2

P: 12
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.:

Expand|Select|Wrap|Line Numbers
  1. header('Content-type: wacky/doodle');
  2. include('header.php');
  3.  
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:
May 30 '07 #3

pbmods
Expert 5K+
P: 5,821
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\vhosts\.....\httpdocs\login\login.php on line 23.
May 31 '07 #4

P: 12
Thank you very much. I did per your advise and finally worked out for me. Thx once more.
May 31 '07 #5

pbmods
Expert 5K+
P: 5,821
You're welcome.

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

Post your reply

Sign in to post your reply or Sign up for a free account.