0

hii..
i am getting error msg when running this program. pls verify if anybody can..

code:

<?php    
    session_start();
    //session_register("username");
    //session_encode();
    //$url="Location:loggedin.php?PHPSESSID=".$PHPSESSID;
    // header($url);
     if(isset($_POST['submit']))
     {   if(empty($password)){echo "No password specified";}
        $connection=mysql_connect("localhost","wwwuser_raja","kalika");
      if(!$connection)
        {echo"<b>connection not set...</b><br>";}
            $sel=mysql_select_db("wwwuser_raja");
      if(!$sel)
        {echo"<b>database not selected...</b><br>";}
     $query="select password from users where username='".$username."'";
     $result=mysql_query($query);
     if($row=mysql_fetch_array($result))
     {
         if(!(md5($password)==$row["password"]))
           {echo "Wrong Password !";} 
     }
     else
     {echo "<b>User does not exists  !!</b>";}    
     //session_start();
     session_register("username");
     session_encode();
     $url="Location:loggedin.php?PHPSESSID=".$PHPSESSID;
     header($url); 
  }    
?>

error:

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /hsphere/local/home/wwwuser/home.mishra.biz/addressbook/login.php:1) in /hsphere/local/home/wwwuser/home.mishra.biz/addressbook/login.php on line 2 Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /hsphere/local/home/wwwuser/home.mishra.biz/addressbook/login.php:1) in /hsphere/local/home/wwwuser/home.mishra.biz/addressbook/login.php on line 2 Warning: Cannot modify header information - headers already sent by (output started at /hsphere/local/home/wwwuser/home.mishra.biz/addressbook/login.php:1) in /hsphere/local/home/wwwuser/home.mishra.biz/addressbook/login.php on line 28

pls veryfy soon ..waiting for rply..

Edited by mike_2000_17: Fixed formatting

3
Contributors
3
Replies
4
Views
10 Years
Discussion Span
Last Post by ryan_vietnow
0

You have already output something to the page before you start the session which must come before any headers are sent ie. data sent to the page. I'm not sure where in your file you have that

0

You have already output something to the page before you start the session which must come before any headers are sent ie. data sent to the page. I'm not sure where in your file you have that

i know the concept yhay you are telling"session should be started 1st"

but wher is the problem
pls try if you can find the problem..
my code:-

<?php
session_start();
//session_register("username");
//session_encode();
//$url="Location:loggedin.php?PHPSESSID=".$PHPSESSID;
// header($url);
if(isset($_POST['submit']))
{ if(empty($password)){echo "No password specified";}
$connection=mysql_connect("localhost","wwwuser_raja","kalika");
if(!$connection)
{echo"<b>connection not set...</b><br>";}
$sel=mysql_select_db("wwwuser_raja");
if(!$sel)
{echo"<b>database not selected...</b><br>";}
$query="select password from users where username='".$username."'";
$result=mysql_query($query);
if($row=mysql_fetch_array($result))
{
if(!(md5($password)==$row["password"]))
{echo "Wrong Password !";}
}
else
{echo "<b>User does not exists !!</b>";}
//session_start();
session_register("username");
session_encode();
$url="Location:loggedin.php?PHPSESSID=".$PHPSESSID;
header($url);
}
?>

error:-
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /hsphere/local/home/wwwuser/home.mishra.biz/addressbook/login.php:1) in /hsphere/local/home/wwwuser/home.mishra.biz/addressbook/login.php on line 2 Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /hsphere/local/home/wwwuser/home.mishra.biz/addressbook/login.php:1) in /hsphere/local/home/wwwuser/home.mishra.biz/addressbook/login.php on line 2 Warning: Cannot modify header information - headers already sent by (output started at /hsphere/local/home/wwwuser/home.mishra.biz/addressbook/login.php:1) in /hsphere/local/home/wwwuser/home.mishra.biz/addressbook/login.php on line 28

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.