decneo Posted April 22, 2010 Share Posted April 22, 2010 i can sigup to my local site but when i've tried to login it appears sth like this Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at D:\AppServ\www\koko\userlogin\chkmember.php:1) in D:\AppServ\www\koko\userlogin\chkmember.php on line 19 Warning: Cannot modify header information - headers already sent by (output started at D:\AppServ\www\koko\userlogin\chkmember.php:1) in D:\AppServ\www\koko\userlogin\chkmember.php on line 22 here is my php code : <? $user_login=$_POST[user_login]; $pass_login=$_POST[pass_login]; if ($user_login=="" or $pass_login=="") { echo "<h3>ERROR : ກະລຸນາກຼອກຂໍ້ມູນໃຫ້ຄົບຖ້ວນ <h3>"; exit(); } include "connect.php"; $connect=mysql_connect("$hostname_connect","$username_connect","$password_connect")or die("cannot connect"); mysql_select_db("$database_connect",$connect)or die("cannot select DB"); $sql="select * from tb_member where username='$user_login' and password='$pass_login'"; $result=mysql_query($sql); $num=mysql_num_rows($result); mysql_close(); if($num<=0) { echo "<h3>ERROR : Username ຫຼື Password ບໍ່ຖືກຕ້ອງ</h3>"; } else { session_start(); $_SESSION[sess_userid]=session_id(); $_SESSION[sess_username]=$user_login; header("Location: main.php"); } ?> best regards, koko Quote Link to comment https://forums.phpfreaks.com/topic/199400-member-sessoin-problem-please-help/ Share on other sites More sharing options...
andrewgauger Posted April 23, 2010 Share Posted April 23, 2010 Both session_start() and header() need to be executed before any content is output (such as echo and anything outside <?) Just assign a $error variable what you want output and output it after you execute session_start or header() (although no one can read what your page prints, if the browser is changing locations. Also after your header(redirect) put an exit; Quote Link to comment https://forums.phpfreaks.com/topic/199400-member-sessoin-problem-please-help/#findComment-1046759 Share on other sites More sharing options...
decneo Posted April 23, 2010 Author Share Posted April 23, 2010 Both session_start() and header() need to be executed before any content is output (such as echo and anything outside <?) Just assign a $error variable what you want output and output it after you execute session_start or header() (although no one can read what your page prints, if the browser is changing locations. Also after your header(redirect) put an exit; it still have the same result :'( Quote Link to comment https://forums.phpfreaks.com/topic/199400-member-sessoin-problem-please-help/#findComment-1046795 Share on other sites More sharing options...
oni-kun Posted April 23, 2010 Share Posted April 23, 2010 Why not start the session at the beginning? You clearly are outputting something (Maybe even something as simple as a newline or space before <?) that will prevent it from sending. And please use real php tags, <?php Quote Link to comment https://forums.phpfreaks.com/topic/199400-member-sessoin-problem-please-help/#findComment-1046796 Share on other sites More sharing options...
decneo Posted April 23, 2010 Author Share Posted April 23, 2010 Why not start the session at the beginning? You clearly are outputting something (Maybe even something as simple as a newline or space before <?) that will prevent it from sending. And please use real php tags, <?php ok,i've changed but i got this session_start(); Warning: Cannot modify header information - headers already sent by (output started at D:\AppServ\www\koko\userlogin\chkmember.php:2) in D:\AppServ\www\koko\userlogin\chkmember.php on line 22 here is my new code : session_start(); <?php $user_login=$_POST[user_login]; $pass_login=$_POST[pass_login]; if ($user_login=="" or $pass_login=="") { echo "<h3>ERROR : ກະລຸນາກຼອກຂໍ້ມູນໃຫ້ຄົບຖ້ວນ <h3>"; exit(); } include "connect.php"; $connect=mysql_connect("$hostname_connect","$username_connect","$password_connect")or die("cannot connect"); mysql_select_db("$database_connect",$connect)or die("cannot select DB"); $sql="select * from tb_member where username='$user_login' and password='$pass_login'"; $result=mysql_query($sql); $num=mysql_num_rows($result); mysql_close(); if($num<=0) { echo "<h3>ERROR : Username ຫຼື Password ບໍ່ຖືກຕ້ອງ</h3>"; } else { $_SESSION[sess_userid]=session_id(); $_SESSION[sess_username]=$user_login; header("Location: main.php"); exit; } ?> regards, Decneo Quote Link to comment https://forums.phpfreaks.com/topic/199400-member-sessoin-problem-please-help/#findComment-1046798 Share on other sites More sharing options...
andrewgauger Posted April 23, 2010 Share Posted April 23, 2010 <?php session_start(); Quote Link to comment https://forums.phpfreaks.com/topic/199400-member-sessoin-problem-please-help/#findComment-1046799 Share on other sites More sharing options...
decneo Posted April 23, 2010 Author Share Posted April 23, 2010 <?php session_start(); ok,but still have this : Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at D:\AppServ\www\koko\userlogin\chkmember.php:1) in D:\AppServ\www\koko\userlogin\chkmember.php on line 2 Warning: Cannot modify header information - headers already sent by (output started at D:\AppServ\www\koko\userlogin\chkmember.php:1) in D:\AppServ\www\koko\userlogin\chkmember.php on line 22 please help me to figure my problem out best regards, Decneo Quote Link to comment https://forums.phpfreaks.com/topic/199400-member-sessoin-problem-please-help/#findComment-1046802 Share on other sites More sharing options...
andrewgauger Posted April 23, 2010 Share Posted April 23, 2010 Try deleting EVERYTHING above the session_start line by putting your cursor on the s and pressing backspace until you are sure there is nothing before the s and then try typing in <?php and press enter. Also, try opening the file in a different editor, it might be something wrong with the editor. Quote Link to comment https://forums.phpfreaks.com/topic/199400-member-sessoin-problem-please-help/#findComment-1046803 Share on other sites More sharing options...
decneo Posted April 23, 2010 Author Share Posted April 23, 2010 Try deleting EVERYTHING above the session_start line by putting your cursor on the s and pressing backspace until you are sure there is nothing before the s and then try typing in <?php and press enter. Also, try opening the file in a different editor, it might be something wrong with the editor. i did like you told me bro but got the same problem i use dreaweaver for my editor and also try notepad. best regards, Decneo Quote Link to comment https://forums.phpfreaks.com/topic/199400-member-sessoin-problem-please-help/#findComment-1046822 Share on other sites More sharing options...
andrewgauger Posted April 23, 2010 Share Posted April 23, 2010 found this on a post: 100% working solution Step one :- Search & Open PHI.INI Step Two:- Search session.cache_limiter Step three:- put " public " in front of session.cache_limiter Like session.cache_limiter =public Thats it . http://www.phpbuilder.com/board/showthread.php?t=10310794 Quote Link to comment https://forums.phpfreaks.com/topic/199400-member-sessoin-problem-please-help/#findComment-1046823 Share on other sites More sharing options...
PFMaBiSmAd Posted April 23, 2010 Share Posted April 23, 2010 output started at D:\AppServ\www\koko\userlogin\chkmember.php:1 (line 1) You either have some character(s) in the file before the <?php tag or your file has been saved as a UTF-8 encoded file and the BOM (Byte Order Mark) characters that your editor placed at the start of the file is the output that is occurring on line 1. The solution is simple. Check if there are any character(s) before the <?php tag and delete them or save your file as a UTF-8 encode file without the BOM or save it as an ANSI encoded file. Quote Link to comment https://forums.phpfreaks.com/topic/199400-member-sessoin-problem-please-help/#findComment-1046824 Share on other sites More sharing options...
decneo Posted April 23, 2010 Author Share Posted April 23, 2010 found this on a post: 100% working solution Step one :- Search & Open PHI.INI Step Two:- Search session.cache_limiter Step three:- put " public " in front of session.cache_limiter Like session.cache_limiter =public Thats it . http://www.phpbuilder.com/board/showthread.php?t=10310794 i've changed it but still have the same problem, i'll rewrote the file maybe it will work thankyou bro . Best regards, Decneo Quote Link to comment https://forums.phpfreaks.com/topic/199400-member-sessoin-problem-please-help/#findComment-1046828 Share on other sites More sharing options...
decneo Posted April 23, 2010 Author Share Posted April 23, 2010 output started at D:\AppServ\www\koko\userlogin\chkmember.php:1 (line 1) You either have some character(s) in the file before the <?php tag or your file has been saved as a UTF-8 encoded file and the BOM (Byte Order Mark) characters that your editor placed at the start of the file is the output that is occurring on line 1. The solution is simple. Check if there are any character(s) before the <?php tag and delete them or save your file as a UTF-8 encode file without the BOM or save it as an ANSI encoded file. ok,it works save as ANSI file thank you very much Big brother. 100/100 best regards, Decneo Quote Link to comment https://forums.phpfreaks.com/topic/199400-member-sessoin-problem-please-help/#findComment-1046830 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.