Click here to Skip to main content
15,909,747 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\inetpub\vhosts\outboxnews.co.in\httpdocs\admin.php:3) in C:\inetpub\vhosts\outboxnews.co.in\httpdocs\admin.php on line 4

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\inetpub\vhosts\outboxnews.co.in\httpdocs\admin.php:3) in C:\inetpub\vhosts\outboxnews.co.in\httpdocs\admin.php on line 4




my code is


PHP
<?php
session_start();
include("connect.php");
$u_name = $_POST['email'];
$u_pass = $_POST['pwd'];
if ($_POST['Submit']=='Login')
{
$sql = "SELECT * FROM user WHERE
            username = '$u_name' AND
            password = '$u_pass'";

$result = mysql_query($sql) or die (mysql_error());
$cmd=mysql_fetch_array($result);
$num = mysql_num_rows($result);


if ($num)
{


$_SESSION['username'] = $u_name;
    echo "META HTTP-EQUIV=Refresh Content=0; URL=a.php";

    exit;



}
else
{
   $errore_msg="Your username or Password is incorrect";


}

}


?>
Posted
Updated 14-May-12 23:04pm
v2
Comments
Sandeep Mewara 15-May-12 4:56am    
This is not a well framed question! We cannot work out what you are trying to do/ask from the post. Please elaborate and be specific.
Use the "Improve question" link to edit your question and provide better information.

The message means that some output has already been sent to the browser before session_start() was called. I can't see any in your code, but you should check that there are no spaces, blank lines or even a BOM (byte order marker) before your opening <php bracket.

The BOM can be tricky to find and dispose of, depending on your text editor - Notepad++[^] has an option to change the file encoding to "UTF-8 wihout BOM", which is very handy.
 
Share this answer
 
Comments
Mohibur Rashid 15-May-12 5:14am    
we post in the same time with same messages :)))))))
Even though this code seems that you should not have any error like this.

But I am not sure how your actual file is. Anyway, try to understand this:

PHP send all header before you send any data, when you call session_start your browser will create an warning.

What is the possible reasons for the error:
1. You have wrote some code before calling session start you didnt display. below example will show such a failure
HTML
<HTML>
<?php
session_start();
?>
</HTML>


the above code will must create a warning.

2. Another possibility: you may have written in UTF-8 File format. in this case it is very much possible that you have created the file with BOM, if BOM exists then your page will act like this. Convert your file format to UTF-8 Without BOM,

USE some smart text editor to view all the character that is going to browser before you start your session. I will suggest NotePad++
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900