Jump to content

the session couldnt work..


irene169

Recommended Posts


i dunno why my session in the page couldnt work.. once i click on the login button after i insert the username and password...it jz show me this -->

--------------------------------------------------------------------------------------------------------------------

Warning: Cannot send session cookie - headers already sent by (output started at c:\phpdev\www\new\session_assign.php:5) in c:\phpdev\www\new\session_assign.php on line 27

Warning: Cannot send session cache limiter - headers already sent (output started at c:\phpdev\www\new\session_assign.php:5) in c:\phpdev\www\new\session_assign.php on line 27
Welcome to Advance2004 Sdn. Bhd. , shian
Click here to view the shopping catalog. --> Start Shopping

--------------------------------------------------------------------------------------------------------------------


it does show me the session name and message that i want.. but how can i get rid of the warning??...

is there any error ??...

here is my coding -->

[u]form coding [/u]
------------------------------------------------------------------------------------------------------------------------

<html>
<head>
<title>Customer Log-in</title>

<p align="center">
<font size=10 face="Verdana">
Customer Login
</font>
</p>

<br>
<br>

<p align="center">
<font face="Arial Black" size=3 color=483d8b>
<form action="session_assign.php" method="POST">
<label for="username"> Username: </label>
<input type="text" name="username" size="20" max length="30">
<br>
<br>
<br>
<label for="pw">Password:</label>
<input type="password" name="pw" id="pw">
<br>
<br>
<input type="submit" value="Login"><a href="mainpage"></a>
</form>
</p>

<br>
<br>

<p align="center">
<font face="Rockwell Extra Bold" size=5 color=fa8072>
New User? <a href=register.html>Click here</a>
</font>
</p>

</body>
</html>

---------------------------------------------------------------------------------------------------------------------

[u]php coding : [/u]

---------------------------------------------------------------------------------------------------------------------


<html>
<title>User Login Status</title>

<body bgcolor="lightblue">
<?php



$dbase="customer1";
$tname="cus_login";

mysql_connect('localhost') or die("Cannot connect to

the Database");

mysql_select_db("$dbase") or die ("Cannot select

Database");

$user=$_REQUEST['username'];
$password=$_REQUEST['pw'];

$query="SELECT * FROM cus_login WHERE

user_id='$user' and user_pw='$password'";

$result=mysql_query($query);

$coun=mysql_num_rows($result);

if($coun==1)
{
session_start();
$_session['user']=$user;
echo "Welcome to Advance2004 Sdn. Bhd. ,&nbsp;" . $_session['user'] ;

echo "<br>Click here to view the shopping catalog. -->";
?>

<a href="shopping.php"> Start Shopping </a>

<?php


}

else

{

?>


<p align="center">
<font face="rockwell extra bold" size=6>
Login Status
</font>
<br>
<hr>
<br>
<p align="center">
<font face="arial" size="4">
Wrong User ID or Password
Please click here to login again --> <a

href="login_assign.php">Login Form</a>
<br>
If you are not a member, please click here to

register. --> <a href="assign3.php">Registration

Form</a>
</font>
</p>


<?php
}
?>
</body>
</html>

---------------------------------------------------------------------------------------------------------------------

hope some1 can help me in this...

thanks a million...


regards..

irene




Link to comment
Share on other sites

You must place session_start() at the very top of the page (before any whitespace or HTML).

I should also add that starting a session doesn't log anyone in, so it doesn't hurt to always start one.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.