irene169 Posted May 3, 2006 Share Posted May 3, 2006 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 27Warning: 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 27Welcome to Advance2004 Sdn. Bhd. , shianClick 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. , " . $_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 https://forums.phpfreaks.com/topic/8957-the-session-couldnt-work/ Share on other sites More sharing options...
ober Posted May 3, 2006 Share Posted May 3, 2006 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 https://forums.phpfreaks.com/topic/8957-the-session-couldnt-work/#findComment-32904 Share on other sites More sharing options...
irene169 Posted May 3, 2006 Author Share Posted May 3, 2006 Thanks a lot.............thanks a million......:)....it works....:D.... Link to comment https://forums.phpfreaks.com/topic/8957-the-session-couldnt-work/#findComment-32910 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.