i am facing problem in php session..
my code is giving error..
i am giving my code and error message below..
my code:-
[code=php]
<?php
if(isset($_POST['submit']))
{ if(empty($passw ord)){echo "No password specified";}
$connection=mys ql_connect("loc alhost","wwwuse r_raja","kalika ");
if(!$connection )
{echo"<b>connec tion not set...</b><br>";}
$sel=mysql_sele ct_db("wwwuser_ raja");
if(!$sel)
{echo"<b>databa se not selected...</b><br>";}
$query="select password from users where username='".$us ername."'";
$result=mysql_q uery($query);
if($row=mysql_f etch_array($res ult))
{
if(!(md5($passw ord)==$row["password"]))
{echo "Wrong Password !";}
}
else
{echo "<b>User does not exists !!</b>";}
session_start() ;
session_registe r("username") ;
session_encode( );
$url="Location: loggedin.php?PH PSESSID=".$PHPS ESSID;
header($url);
}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Language" content="en-us" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Login</title>
<style type="text/css">
.style1 {
margin-left: 0px;
}
.style2 {
margin-left: 248px;
margin-top: 126px;
}
</style>
</head>
<body>
<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>" style="height: 202px; width: 321px" class="style2">
&nb sp; Enter your information&nbs p; in
the form below &nbs p; & nbsp;
&nb sp; <br />
<br />
&nb sp;
&nb sp;
&nb sp;
&nb sp;
<br />
&nb sp; &nb sp; Username
<input name="username" type="text" maxlength="20" value="<?php if(isset($_POST['username'])) echo $_POST['username'];?>" /> &n bsp; <br />
&nb sp; &nb sp; <br />
&nb sp; &nb sp; Password
<input name="password" type="password" maxlength="20" /> <br />
<br />
&nb sp;
&nb sp;
&nb sp;
&nb sp;
&nb sp;
&nb sp;
<input name="submit" type="submit" value="Login" style="width: 40px; height: 20px" class="style1" /><br />
</form>
</body>
</html>
[/code]
Error msg:-when i am giving the correct username and password..
Warning: session_start() : Cannot send session cookie - headers already sent by (output started at /hsphere/local/home/wwwuser/home.mishra.biz/addressbook/login.php:3) in /hsphere/local/home/wwwuser/home.mishra.biz/addressbook/login.php on line 25 Warning: session_start() : Cannot send session cache limiter - headers already sent (output started at /hsphere/local/home/wwwuser/home.mishra.biz/addressbook/login.php:3) in /hsphere/local/home/wwwuser/home.mishra.biz/addressbook/login.php on line 25 Warning: Cannot modify header information - headers already sent by (output started at /hsphere/local/home/wwwuser/home.mishra.biz/addressbook/login.php:3) in /hsphere/local/home/wwwuser/home.mishra.biz/addressbook/login.php on line 29
can anybody help me...
my code is giving error..
i am giving my code and error message below..
my code:-
[code=php]
<?php
if(isset($_POST['submit']))
{ if(empty($passw ord)){echo "No password specified";}
$connection=mys ql_connect("loc alhost","wwwuse r_raja","kalika ");
if(!$connection )
{echo"<b>connec tion not set...</b><br>";}
$sel=mysql_sele ct_db("wwwuser_ raja");
if(!$sel)
{echo"<b>databa se not selected...</b><br>";}
$query="select password from users where username='".$us ername."'";
$result=mysql_q uery($query);
if($row=mysql_f etch_array($res ult))
{
if(!(md5($passw ord)==$row["password"]))
{echo "Wrong Password !";}
}
else
{echo "<b>User does not exists !!</b>";}
session_start() ;
session_registe r("username") ;
session_encode( );
$url="Location: loggedin.php?PH PSESSID=".$PHPS ESSID;
header($url);
}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Language" content="en-us" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Login</title>
<style type="text/css">
.style1 {
margin-left: 0px;
}
.style2 {
margin-left: 248px;
margin-top: 126px;
}
</style>
</head>
<body>
<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>" style="height: 202px; width: 321px" class="style2">
&nb sp; Enter your information&nbs p; in
the form below &nbs p; & nbsp;
&nb sp; <br />
<br />
&nb sp;
&nb sp;
&nb sp;
&nb sp;
<br />
&nb sp; &nb sp; Username
<input name="username" type="text" maxlength="20" value="<?php if(isset($_POST['username'])) echo $_POST['username'];?>" /> &n bsp; <br />
&nb sp; &nb sp; <br />
&nb sp; &nb sp; Password
<input name="password" type="password" maxlength="20" /> <br />
<br />
&nb sp;
&nb sp;
&nb sp;
&nb sp;
&nb sp;
&nb sp;
<input name="submit" type="submit" value="Login" style="width: 40px; height: 20px" class="style1" /><br />
</form>
</body>
</html>
[/code]
Error msg:-when i am giving the correct username and password..
Warning: session_start() : Cannot send session cookie - headers already sent by (output started at /hsphere/local/home/wwwuser/home.mishra.biz/addressbook/login.php:3) in /hsphere/local/home/wwwuser/home.mishra.biz/addressbook/login.php on line 25 Warning: session_start() : Cannot send session cache limiter - headers already sent (output started at /hsphere/local/home/wwwuser/home.mishra.biz/addressbook/login.php:3) in /hsphere/local/home/wwwuser/home.mishra.biz/addressbook/login.php on line 25 Warning: Cannot modify header information - headers already sent by (output started at /hsphere/local/home/wwwuser/home.mishra.biz/addressbook/login.php:3) in /hsphere/local/home/wwwuser/home.mishra.biz/addressbook/login.php on line 29
can anybody help me...
Comment