mat3000000 Posted January 27, 2011 Share Posted January 27, 2011 Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/bakerde1/public_html/oceangamer.com/login.php:1) in /home/bakerde1/public_html/oceangamer.com/login.php on line 2 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/bakerde1/public_html/oceangamer.com/login.php:1) in /home/bakerde1/public_html/oceangamer.com/login.php on line 2 These are my error messages, here is my code. I don't know if it is the UTF-8 code at the start, but if it is can anyone recommend a binary editor to remove this. If it isn't what is the problem? <?php session_start(); $username = $_POST['username']; $password = base64_decode($_POST['password']); $errors = array(); if($username == 'User Name' || $username == ''){ $errors[] = 'Please enter a valid username'; } if($password == 'Password' || $password == ''){ $errors[] = 'Please enter a valid password'; } $link = mysql_connect("localhost","*****","******") or die ("Could not connect!"); mysql_select_db("chef"); $query = mysql_query("SELECT * FROM `users` WHERE `username`='$username'"); $numrows = mysql_num_rows($query); if ($numrows!=0) { while($row = mysql_fetch_assoc($query)) { $dbusername = $row['username']; $dbpassword = $row['password']; } if ($username==$dbusername&&$password==$dbpassword) { $_SESSION['user'] = $username; while ($row = mysql_fetch_array($res)) { $type = $row['Type']; } if ($type == "0") { header("location: chefpanel.php"); }else{ header("location: restpanel.php"); } } else $errors[] = 'Username or Password Incorrect'; } else $errors[] = 'Username or Password Incorrect'; ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> Quote Link to comment https://forums.phpfreaks.com/topic/225874-cannot-send-session-cookie-eaders-already-sent/ Share on other sites More sharing options...
nikolajpop Posted January 27, 2011 Share Posted January 27, 2011 Check this if ($type == "0") { header("location: chefpanel.php"); }else{ header("location: restpanel.php"); } These two php files can have Meta and document headers. Quote Link to comment https://forums.phpfreaks.com/topic/225874-cannot-send-session-cookie-eaders-already-sent/#findComment-1166117 Share on other sites More sharing options...
Psycho Posted January 27, 2011 Share Posted January 27, 2011 So, that is the file login.php? Is there ANYTHING before the first opening "<?php" tag - including spaces, line breaks, etc? EDIT I don't know if it is the UTF-8 code at the start, but if it is can anyone recommend a binary editor to remove this. Wait, what application are you using to edit your files? You must save as a plain text file. There are plenty of free text editors available. If all else fails use notepad. Quote Link to comment https://forums.phpfreaks.com/topic/225874-cannot-send-session-cookie-eaders-already-sent/#findComment-1166120 Share on other sites More sharing options...
mat3000000 Posted January 27, 2011 Author Share Posted January 27, 2011 Thanks everyone, I just copied to notepad ++ and saved, that gets rid of the hidden tag at the start. Quote Link to comment https://forums.phpfreaks.com/topic/225874-cannot-send-session-cookie-eaders-already-sent/#findComment-1166136 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.