cluce Posted May 11, 2007 Share Posted May 11, 2007 All I did was add the sql insert command because I want to record the date/time every time soneone logs on and now I am getting these warnings and I can't get rid of them. This was code was working before I did that. This is driving me bannanas. Can someone please tell me whats going on?? Here are my errors... Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\wamp\www\userlogin.php:1) in C:\wamp\www\userlogin.php on line 4 Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\userlogin.php:1) in C:\wamp\www\userlogin.php on line 50 here is my code... <?php //initialize the session if (!isset($_SESSION)) { session_start(); } //check for required fields from the form if ((!isset($_POST["username"])) || (!isset($_POST["password"]))) { header("Location: user_logon.html"); exit; } //connect to server and select database $mysqli = mysqli_connect("localhost", "root", "", "test"); //create and issue the query $sql = "SELECT f_name, l_name FROM auth_users WHERE username = '".$_POST["username"]."' AND password = PASSWORD('".$_POST["password"]."')"; $result = mysqli_query($mysqli, $sql) or die(mysqli_error($mysqli)); //get the number of rows in the result set; should be 1 if a match if (mysqli_num_rows($result) == 1) { //if authorized, get the values of f_name l_name while ($info = mysqli_fetch_array($result)) { $f_name = stripslashes($info['f_name']); $l_name = stripslashes($info['l_name']); } //set authorization cookie setcookie("auth", "1", 0, "/", "yourdomain.com", 0); $_SESSION['usersname'] = $f_name . " " . $l_name; //records logon event //$sql = "INSERT INTO Events (user, Date) VALUES ('".$_POST['username']."')"; //directs authorized user header("Location: logon.php"); } else { //redirect back to login form if not authorized $_SESSION['error'] = "<font color='red'>Invalid username and/or password combination</font>"; header("Location: user_logon.php"); exit; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/50972-solved-warning-cannot-modify-header-information/ Share on other sites More sharing options...
per1os Posted May 11, 2007 Share Posted May 11, 2007 Make sure there are no "white" spaces at the top of the page, I would copy and paste it into notepad just to be sure there is nothing getting added to the top. For example this would throw an error: --note this space here will throw an error <?php ?> I would check that first. Quote Link to comment https://forums.phpfreaks.com/topic/50972-solved-warning-cannot-modify-header-information/#findComment-250774 Share on other sites More sharing options...
cluce Posted May 11, 2007 Author Share Posted May 11, 2007 I am not sure what was the problem here. I just used my orignal login.php page before I made changes to it. Quote Link to comment https://forums.phpfreaks.com/topic/50972-solved-warning-cannot-modify-header-information/#findComment-250802 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.