Page 1 of 1

Cannot modify header information - headers already sent by..

Posted: Sat Apr 11, 2009 11:58 am
by TheRavolution
Hi there,i hope someone can help me with this. I have a PHP site here that unfortunately, when I try logging in, I get this statement across the top:

Warning: Cannot modify header information - headers already sent by (output started at /home/moneyppc/public_html/includes/db.inc.php:169) in /home/moneyppc/public_html/login.php on line 45, 46, 48

and when I try and log off, it says:

Warning: Cannot modify header information - headers already sent by (output started at /home/moneyppc/public_html/includes/db.inc.php:169) in /home/moneyppc/public_html/login.php on line 68, 71

--------------

I was hoping I could show you guys the source code and have your say on the problem. We're at a standstill and could really use some help. Thanks for anything in advance, heres the source code for login.php:

<?php
@session_start();
include_once("includes/db.inc.php");
include_once("includes/function.php");
$db=new DB();
$db->ConnectToDb();
$MSG="";
$error =0;
$count = 0;
$error_msg="";
$info_msg="";
if(isset($_POST["subf"])){

$query="SELECT * FROM parents WHERE username='".$_POST["username"]."' AND password='". $_POST["password"] ."' and status <> 'Cancelled'";
//echo $query;
$ud=$db->selectFrom($query);
if($ud){
$parent_id = $ud['parent_id'];
//$par_query="SELECT COUNT(*) AS count FROM parent_paid WHERE parent_id=". $parent_id ."";
//echo $query;
//$par_paid_count=$db->selectFrom($par_query);

if($ud['logincount'] == 0 && $ud['totalchildren'] > 0 && $ud['status'] == 'Block'){
$_SESSION['par_id'] = $parent_id;
header("Location: parentsignup.php");
}
elseif ($ud['logincount'] >= 1 && $ud['status'] == 'Block'){
$error =1;
$info_msg="<span style='color: black; font: Verdana, Arial, Helvetica, sans-serif; size:12pt; font-weight:bold'>HI, Thank You for choosing <span style='color: Red;'>Moneyplus101.com</span>, please check your email to confirm & pay your new enrollment package.</span> ";
}
else{
$count = $ud['logincount'] + 1;
$error =0;
$query2 = "UPDATE parents SET logincount = $count WHERE parent_id = $parent_id";
//echo $query;
$qrs=mysql_query($query2);
$_SESSION['pemail'] = $ud['email'];
$_SESSION['par_id'] = $ud['parent_id'];
$_SESSION["username"]= $_POST["username"];
$_SESSION['parent_name'] = $ud['fname']." ".$ud['lname'];
$_SESSION["log_in"]= 1;
$_SESSION["logincount"]= $count;
$_SESSION["pass"]= $_POST["password"];
if(isset($_POST['rem_me'])){
setcookie("cookname", $_SESSION['username'], time()+60*60*24*100, "/");
setcookie("cookpass", $_SESSION['pass'], time()+60*60*24*100, "/");
}
header("Location: phome.php");
}
}else{
$error =1;
$MSG="Invalid Email and Password";
}
}
if(isset($_GET["logoff"])){
logoff();
}
function logoff()
{
// kill session variables
unset($_SESSION["pemail"]);
unset($_SESSION["pass"]);
unset($_SESSION["username"]);
unset($_SESSION["log_in"]);
unset($_SESSION["par_id"]);
//$_SESSION["branchid"]
session_destroy();
setcookie("sessid", NULL, time()-3600);

// redirect them to anywhere you like.
header("Location: login.php");
}
?>
<?php include_once("includes/header.php"); ?><style type="text/css">
<!--
a:link {
color: #FFF;
}
a:visited {
color: #FFF;
}
a:hover {
color: #FFF;
}
a:active {
color: #FFF;
font-weight: bold;
font-size: 10px;
}
-->
</style>
<br /><br />
<script language="javascript">
function fnforgot(imgWidth,imgHeight,url) {
url1=url;
var attributes="";
var WinWidth = parseInt(imgWidth) + 50;
var WinHeight = parseInt(imgHeight) +80;

if ((WinWidth != 800) && (WinHeight != 572))
WinVars = 'toolbar=no,menubar=no,width='+escape(WinWidth)+',height='+escape(WinHeight)+',top=250,left=300,resizable=no';
else
WinVars = 'toolbar=no,menubar=no,scrollbars=yes,top=250,left=300,resizable=no';
window.open(url1,"Image",WinVars);
}
function MakeTime()
{}
function ShowClock()
{}
</script>
<div id="container">
<table width="100%" height="454" border="0">
<tr>
<td colspan="2">
<br />
<div align="right">
<?php include_once("logintop.php"); ?>
</div>
</td>
<td width="5%">&nbsp;</td>
</tr>
<tr>
<tr>
<td height="31">&nbsp;</td>
<td><img src="/images/logox.png" width="285" height="60" border="0" /></td>
<td>&nbsp;</td>
</tr>
<tr>
<td width="10%">&nbsp;</td>
<td width="80%">
<form id="test" action="#" method="post" enctype="multipart/form-data">
<fieldset style="background-color:#FFFFFF; font-size: 10px; color: #FFF; font-family: Verdana, Geneva, sans-serif; font-weight: bold;">
<table width="1057" height="266" background="http://www.moneyplus101.com/images/phplogin.png">
<tr>
<td height="20" class="text_head">&nbsp;</td>
<td class="text_head">&nbsp;</td>
<td class="text_head">&nbsp;</td>
<td class="text_head">&nbsp;</td>
</tr>
<tr>
<td class="text_head">&nbsp;</td>
<td class="text_head">Sign Into Your Account</td>
<td class="text_head">&nbsp;</td>
<td class="text_head">&nbsp;</td>
</tr>
<tr>
<td width="42" height="216">&nbsp;</td>
<td width="293"><table>
<?php if($MSG !="") {?>
<tr>
<td colspan="2" align="left" style="color: #FF0000; font-weight:bold; padding-left:18px;"><?php echo $MSG; ?></td>
</tr>
<?php }?>
<?php if($info_msg !="") {?>
<tr>
<td height="3" colspan="2"><?php echo $info_msg; ?></td>
</tr>
<?php }?>
<tr>
<td height="42"><div class="form-row">
<div class="field-label">
<label for="username2" style="color:#FFF; font-family: Verdana, Geneva, sans-serif; font-size: 12px; font-weight: bold;">Your Email:</label>
</div>
<div class="field-widget">
<input type="text" name="username" id="username2" class="required" title="Enter your user name" />
</div>
</div></td>
</tr>
<tr>
<td><div class="form-row">
<div class="field-label">
<label for="password" style="color:#FFF; font-size: 12px; font-family: Verdana, Geneva, sans-serif; font-weight: bold;">Money Plus Password:</label>
</div>
<div class="field-widget">
<input type="password" name="password" id="password" class="required" title="Enter your password" />
</div>
</div></td>
</tr>
<tr>
<td><div class="form-row">
<div class="field-label">
<label for="rem_me" style="color:#FFF; font-size: 10px; font-family: Verdana, Geneva, sans-serif; font-weight: bold;">Remember Me:</label>
</div>
<div class="field-widget">
<input type="checkbox" name="rem_me" id="rem_me"/>
</div>
</div></td>
</tr>
<tr>
<td height="26"><input type="submit" value="Submit" name="subf"/>
&nbsp;<a href="javascript:fnforgot(500,300,'forgetpassword.php')">Forgot Password?</a></td>
</tr>
</table></td>
<td width="41">&nbsp;</td>
<td width="661">&nbsp;</td>
</tr>
</table>
</fieldset>
</form>
</td>
<td width="10%">&nbsp;</td>
</tr>
</table>
</div>

<?php include_once("includes/footer.php"); ?>

Re: Cannot modify header information - headers already sent

Posted: Sat Apr 11, 2009 12:45 pm
by McInfo
viewtopic.php?t=1157

Edit: This post was recovered from search engine cache.

Re: Cannot modify header information - headers already sent by..

Posted: Sat Apr 11, 2009 12:48 pm
by TheRavolution
nvm, for future reference.. it was a space at the end of the closing php. thanks anyways!