illuz1on Posted September 10, 2007 Share Posted September 10, 2007 Hey, Getting this error from my login.php, anyone know why it might be happening? Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/remember/public_html/admin/login.php:1) in /home/remember/public_html/admin/login.php on line 2 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/remember/public_html/admin/login.php:1) in /home/remember/public_html/admin/login.php on line 2 Welcome to the remember online administration section..Please login... Then displays the fields... Thanks alot, Chris <?php session_start(); include "db.php"; if ($_GET["op"] == "login") { if (!$_POST["username"] || !$_POST["password"]) { die("You need to provide a username and password to access this page. This is a restricted area. Information Logged."); } $q = "SELECT * FROM `remusers` " ."WHERE `username`='".$_POST["username"]."' " ."AND `password`='".$_POST["password"]."' " ."LIMIT 1"; $r = mysql_query($q); if ( $obj = @mysql_fetch_object($r) ) { $_SESSION["valid_id"] = $obj->id; $_SESSION["valid_user"] = $_POST["username"]; $_SESSION["valid_time"] = time(); $username = $_POST["username"]; setcookie("admin",1); Header("Location: admin.php"); } else { die("Sorry, could not log you in. Wrong login information."); } } else { echo "Welcome to the remember online administration section.."; echo "Please login..."; echo "<form action=\"?op=login\" method=\"POST\">"; echo "Username: <input name=\"username\" size=\"15\"><br />"; echo "Password: <input type=\"password\" name=\"password\" size=\"8\"><br />"; echo "<input type=\"submit\" value=\"Login\">"; echo "</form>"; } ?> Link to comment https://forums.phpfreaks.com/topic/68705-login-script-problem/ Share on other sites More sharing options...
phat_hip_prog Posted September 10, 2007 Share Posted September 10, 2007 Session auto start is probably on in your php.ini file, it might not be the best but I use: try { if ( !@ ( session_id() ) ) throw new Exception ("oh no!"); } catch (Exception $e) { session_start(); } If anyone has any other suggestions / improvements here i'd also appreciate! Link to comment https://forums.phpfreaks.com/topic/68705-login-script-problem/#findComment-345406 Share on other sites More sharing options...
Ephialtes Posted September 10, 2007 Share Posted September 10, 2007 Do you think you could post the contents of db.php too? The error looks like you might have called session_start in the db.php too which would cause that error. Link to comment https://forums.phpfreaks.com/topic/68705-login-script-problem/#findComment-345432 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.