•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 375,172 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,109 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 16001 | Replies: 4
![]() |
•
•
Join Date: Jun 2006
Posts: 10
Reputation:
Rep Power: 3
Solved Threads: 1
Whenever i run session in server than it show this problem
Warning: session_start(): Cannot send session cache limiter - headers already sent
so pls help me
this is simple login prog when user enter into nxt page it name will show i want to store its name in session
i m giving full code wht i m using if thr is anything wrong pls tell me
<? @session_start();?>
<!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>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<link rel="stylesheet" href="style.css" type="text/css">
<body topmargin="0" leftmargin="0">
<table width="100%" cellspacing="0" cellpadding="0" border="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"))
{
//header("Location:admin_page.php");
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 users WHERE firstname='$f_name' and lastname='$l_name' and password='$pass' ";
$result = mysql_query($query);
for ($i = 0; $i < mysql_num_rows($result); $i++)
{
$id = mysql_result($result, $i, "id");
$fname = mysql_result($result, $i, "firstname");
$lname = mysql_result($result, $i, "lastname");
$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;
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'>";
//header("Location:new_user.php");
exit;
}
?>
</td>
</tr>
</table>
</BODY>
</HTML>
Warning: session_start(): Cannot send session cache limiter - headers already sent
so pls help me
this is simple login prog when user enter into nxt page it name will show i want to store its name in session
i m giving full code wht i m using if thr is anything wrong pls tell me
<? @session_start();?>
<!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>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<link rel="stylesheet" href="style.css" type="text/css">
<body topmargin="0" leftmargin="0">
<table width="100%" cellspacing="0" cellpadding="0" border="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"))
{
//header("Location:admin_page.php");
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 users WHERE firstname='$f_name' and lastname='$l_name' and password='$pass' ";
$result = mysql_query($query);
for ($i = 0; $i < mysql_num_rows($result); $i++)
{
$id = mysql_result($result, $i, "id");
$fname = mysql_result($result, $i, "firstname");
$lname = mysql_result($result, $i, "lastname");
$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;
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'>";
//header("Location:new_user.php");
exit;
}
?>
</td>
</tr>
</table>
</BODY>
</HTML>
Re: Warning: session_start(): Cannot send session cache limiter - headers already sent
#2
Jun 1st, 2006
Headers already sent refers to HTTP Headers.
The server cannot send any more http headers if the HTTP Content has started sending.
In PHP code, this means you have ouput something to the page with echo or print etc.
PHP will not output any whitespace in between php tags, However, for anything outside php tags, (eg: html) whitespaces, linebreaks are sent as HTTP Content.
Sometimes this your editor may add whitespace also.
To prevent whitespace from being sent before you send all your headers, make sure the <?php is right at the top of the php script, and there are no lines or white space in between.
You can also use output buffering, ob_start() to buffer your PHP output before sending it to HTTP. Then use ob_flush() to send http output when you need.
see: http://www.php.net/manual/en/function.ob-start.php
I noticed you have //header("Location:admin_page.php"); in your page. You can use the output buffering to allow you to send this header even after you have echo and html output in your php.
The server cannot send any more http headers if the HTTP Content has started sending.
In PHP code, this means you have ouput something to the page with echo or print etc.
PHP will not output any whitespace in between php tags, However, for anything outside php tags, (eg: html) whitespaces, linebreaks are sent as HTTP Content.
Sometimes this your editor may add whitespace also.
To prevent whitespace from being sent before you send all your headers, make sure the <?php is right at the top of the php script, and there are no lines or white space in between.
You can also use output buffering, ob_start() to buffer your PHP output before sending it to HTTP. Then use ob_flush() to send http output when you need.
see: http://www.php.net/manual/en/function.ob-start.php
I noticed you have //header("Location:admin_page.php"); in your page. You can use the output buffering to allow you to send this header even after you have echo and html output in your php.
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
•
•
Join Date: May 2006
Posts: 13
Reputation:
Rep Power: 3
Solved Threads: 0
Re: Warning: session_start(): Cannot send session cache limiter - headers already sent
#3
Jun 11th, 2006
•
•
Join Date: Jul 2004
Location: North East Indiana
Posts: 491
Reputation:
Rep Power: 5
Solved Threads: 20
Re: Warning: session_start(): Cannot send session cache limiter - headers already sen
#4
Jun 18th, 2006
Works fine for me. Attached is the code I copied and pasted, so you have at least a file that worked.
My test was done with EasyPHP, with the PHP version upgraded to 5.04.
My test was done with EasyPHP, with the PHP version upgraded to 5.04.
www.uncreativelabs.net
Old computers are getting to be a lost art. Here at Uncreative Labs, we still enjoy using the old computers. Sometimes we want to see how far a particular system can go, other times we use a stock system to remind ourselves of what we once had.
Old computers are getting to be a lost art. Here at Uncreative Labs, we still enjoy using the old computers. Sometimes we want to see how far a particular system can go, other times we use a stock system to remind ourselves of what we once had.
Re: Warning: session_start(): Cannot send session cache limiter - headers already sent
#5
Jun 18th, 2006
Pass the header before any HTML tags or else it would show errors
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
Similar Threads
- session variable error (PHP)
- Need Help Correcting These errors (PHP)
- URL Redirection in PHP (PHP)
- error message with sessions (PHP)
Other Threads in the PHP Forum
- Previous Thread: PHP "hello" in different languages ???
- Next Thread: Session Login Problem


Linear Mode