Warning: session_start(): Cannot send session cookie - headers already sent by
i want to use session in my prog and this error comes every times due 2 which i cann't use session which is vry important for me.
but whn i run the same prog in my computer i.e. localhost it run correctly but when i load that file in the server than this error comes.
so pls help me to avoid this session error
my boss fire on me :sad: :sad: :sad: :sad: :sad: :sad: :sad: :sad:
pls pls help me
here is the my prog ----------------
<? ob_start();
session_start();?>
<?php
include"db_config.php";
$connect = mysql_connect("$db_host", "$db_user", "$db_password");
mysql_select_db("$db_name", $connect) or die(mysql_error());
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0046)http://acmserver.cs.ucr.edu/~nkumar/vision.htm -->
<HTML>
<HEAD><TITLE>Bankon Us</TITLE>
<body topmargin="0" leftmargin="0">
<tr>
<TD align=center>
<table cellpadding="0" cellspacing="0" border=0 width="100%">
<tr><td height="25"> </td></tr>
<tr>
<td width="50%" align="right">
<?php
$_SESSION['admfname']= $_POST['fname'];
$_SESSION['admlname']= $_POST['lname'];
$_SESSION['admpassword']=$_POST['password'];
if (($_SESSION['admfname'] == "peter") and ($_SESSION['admlname'] == "gewant") and ($_SESSION['admpassword'] == "approvalagent"))
{
echo "<meta http-equiv='Refresh' content='0; url=admin_page.php'>";
exit;
}
$f_name= $_POST['fname'];
$l_name= $_POST['lname'];
$pass= $_POST['password'];
if($_POST['submit'] != "Login")
{
?>
<table border="0" cellpadding="5" cellspacing="3" width="80%" class="form-noindent">
<tr><td bgColor="#ff9900">
<form method="post" action="<?php $_SERVER['PHP_SELF']?>">
<input type="hidden" name="agent" value="access">
<table border="0" width="100%">
<tr>
<td colspan="3" align="center" class="heading">Sign in with your<br> Account</td>
</tr>
<tr><td> </td></tr>
<tr>
<td> </td>
<td class="textform">First Name :</td>
<td class="forms" valign="top">
<input name="fname" class="cartForm" size=20 type="text"></td>
</tr>
<tr>
<td> </td>
<td class="textform">Last Name :</td>
<input name="lname" class="cartForm" size=10 type="hidden">
<td class="forms" valign="top">
<input name="lname" class="cartForm" size=20 type="text"></td>
</tr>
<tr>
<td> </td>
<td class="textform">Password :</td>
<td class="forms" valign="top">
<input class="cartForm" name="password" size=20 type="password"></td>
</tr>
<tr>
<td valign="top" colspan="3" align="center">
<input type="submit" name="submit" value="Login" class="cartForm" >
</td>
</tr>
<tr><td colspan="3"> </td></tr>
<tr>
<td colspan="2" align="center"><div class="leo"><a href="forget.php">Forget Password</a></div></td>
<td align="center"><div class="leo"><a href="order.php">New user click here</a></div></td>
</tr>
</table>
</form>
</td></tr>
</table>
</td>
<td width="50%" align="center"><img src="images/online.jpg"></td>
</tr>
</table>
<br><br>
<?php }
elseif($f_name== "" or $l_name== "" or $pass== "")
{
?>
<table border="0" cellpadding="5" cellspacing="3" width="80%" class="form-noindent">
<tr><td bgcolor="#00CC99">
<form method="post" action="<?php $_SERVER['PHP_SELF'] ?>">
<input type="hidden" name="agent" value="access">
<table border="0" width="100%">
<tr>
<td colspan="3" align="center" class="heading">Sign in with your Account</td>
</tr>
<tr><td> </td></tr>
<tr><td colspan="3" align="center" class="heading">Please fill all the fields</td></tr>
<tr><td> </td></tr>
<tr>
<td> </td>
<td class="textform">First Name :</td>
<td class="forms" valign="top">
<input name="fname" class="cartForm" size=20 type="text"></td>
</tr>
<tr>
<td> </td>
<td class="textform">Last Name :</td>
<input name="lname" class="cartForm" size=10 type="hidden">
<td class="forms" valign="top">
<input name="lname" class="cartForm" size=20 type="text"></td>
</tr>
<tr>
<td> </td>
<td class="textform">Password :</td>
<td class="forms" valign="top">
<input class="cartForm" name="password" size=20 type="password"></td>
</tr>
<tr>
<td valign="top" colspan="3" align="center">
<input type="submit" name="submit" value="Login" class="cartForm" >
</td>
</tr>
<tr><td colspan="3"> </td></tr>
<tr>
<td colspan="2" align="center"><div class="leo"><a href="forget.php">Forget Password</a></div></td>
<td align="center"><div class="leo"><a href="order.php">New user click here</a></div></td>
</tr>
</table>
</form>
</td></tr>
</table>
</td>
<td width="50%" align="center"><img src="images/login1.jpg" width="300" height="200"></td>
</tr>
</table>
<?php
}
else {
$query = "SELECT * from helpagent WHERE first='$f_name' and last='$l_name' and password='$pass' ";
$result = mysql_query($query);
for ($i = 0; $i < mysql_num_rows($result); $i++)
{
$id = mysql_result($result, $i, "agentid");
$fname = mysql_result($result, $i, "first");
$lname = mysql_result($result, $i, "last");
$pas = mysql_result($result, $i, "password");
if (("$f_name" == "$fname") and ("$l_name" == "$lname") and ("$pass" == "$pas"))
{
$_SESSION['sfname'] = $f_name;
$_SESSION['slname'] = $l_name;
$_SESSION['sid'] = $id;
echo "<meta http-equiv='Refresh' content='0; url=user_page.php'>";
exit;
}//if loop
}//for loop
echo "<meta http-equiv='Refresh' content='0; url=new_user.php'>";
exit;
}
?>
<tr><td> </td></tr>
<tr><td> </td></tr>
<tr>
<td>
<table border="0" width="100%">
<tr><td align="center" class="copy">Copyright © 2006 www.bankon.us All Rights Reserved</td></tr>
</table>
</td>
</tr>
</td>
</tr>
</table>
</BODY>
</HTML>