Possible Duplicates:
Warning: Cannot modify header information - headers already sent by
what is output buffering?
I recently bought a hosting plan from Bluehost and moved my website here. Before, my website was working, and I haven't recieved any errors, but now, when I try to login I recieve this error:
Warning: Cannot modify header information - headers already sent by (output started at /home/rugbyspi/public_html/inc/offline_header.php:15) in /home/rugbyspi/public_html/index.php on line 84
The problem is the header function. I think I can't use this function in middle of the code, but on my other host I can do this. Any idea how to fix this problem?
<?php
session_start();
if (isset($_SESSION['username'])) {
include_once('inc/homepage_header.php');
include_once('lib/stats_func.php');
include_once('lib/user_time_func.php');
update_last_active($username);
?>
<div id="right_menu">
<?php include_once('inc/sidebar_statistics.php'); ?>
<br/>
<?php include_once('inc/sidebar_follow.php'); ?>
</div>
<div id="content">
<div class="text">
<br/>
<h2 class="hr"><?php echo $lang['ann']; ?></h2>
<?php
if(!isset($_REQUEST["start"])) {
$start = 0;
}
else {
$start = $_REQUEST["start"];
}
$query = mysql_query ("SELECT * from news where lang='$language'")
or die ("Couldn't connect to the do database.");
$d=0;
$f=0;
$g=1;
$query = mysql_query ("SELECT * from news where lang='$language' order by id DESC Limit $start, 7") or die ("Couldn't connect to the do database.");
while($news = mysql_fetch_array($query)) {
?>
<h3 class="hr"><font size=1><?php echo $news['tsubmit']; ?></font> <?php echo $news['title']; ?></h3>
<?php
echo $news['body'];
}
echo "<br/><br/><br/>";
echo $lang['pages'] . ': ';
while($order = mysql_fetch_array($query)) {
if($f%7==0) {
echo "<a href='index.php?start=$d'>$g</a>";
$g++;
}
$d++;
$f++;
}
?>
</div>
</div>
<?php
include_once('inc/footer.php');
}
else {
include_once('inc/offline_header.php');
include_once('lib/stats_func.php');
?>
<div id="right_menu">
<?php include_once('inc/sidebar_statistics.php'); ?>
<br/>
<?php include_once('inc/sidebar_follow.php'); ?>
</div>
<div id="content">
<div class="text">
<br/>
<?php echo $lang['welcome']; ?>
<br/><br/>
<?php
if (isset($_POST['submit'])) {
$username = $_POST ['username'];
$password = $_POST ['password'];
$username = strip_tags ($username);
$password = md5 ($password);
mysql_real_escape_string($username);
$query = mysql_query ("SELECT id FROM users WHERE username='$username' AND password='$password'")
or die ("Couldn't connect to the do database.") ;
$result = mysql_fetch_array($query);
if($result) {
$_SESSION['username'] = $username;
header('Location: index.php');
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip=$_SERVER['HTTP_CLIENT_IP'];
}
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
}
else {
$ip=$_SERVER['REMOTE_ADDR'];
}
$time = time();
mysql_query ("INSERT into logins (userid, time, ip)
VALUES ('$result[id]', '$time', '$ip')")
or die ("Couldn't connect to the database.");
}
else {
echo $lang['login_error'];
}
echo '<br/><br/>';
}
?>
<h2 class="hr"><?php echo $lang['about']; ?></h2>
<?php echo $lang['intro']; ?>
</div>
</div>
<?php
}
include_once('inc/footer.php');
?>