I was switched from a Windows server to a Linux server and my code worked before and now it doesn't. I receive the following error message:
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/content/55/9237455/html/liztveten/PHP/header.php:44) in /home/content/55/9237455/html/liztveten/PHP/login.php on line 41
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/content/55/9237455/html/liztveten/PHP/header.php:44) in /home/content/55/9237455/html/liztveten/PHP/login.php on line 41
Warning: Cannot modify header information - headers already sent by (output started at /home/content/55/9237455/html/liztveten/PHP/header.php:44) in /home/content/55/9237455/html/liztveten/PHP/login.php on line 49
I have done many things to try and fix this but nothing seems to work.
I have moved my PHP code above the HTML code.
I have double checked for white space.
I have I have added tmp folder to my root folder and replaced session_start(); with session_save_path('/tmp'); session_start();
I don't know what else to do. This is my original code that worked under a windows server.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Login | My Makeup Bag</title>
</head>
<link type="text/css" href="style.css" rel="stylesheet" />
<body>
<?php
include ('header.php');
?>
<div id="content">
<div id="main">
<?php
include ('dbconn.php');
if (isset ($_POST['submitted'])) {
//set a variable to collect error if any
$errors ="";
if (!empty($_REQUEST['email'])) {
$email = mysqli_real_escape_string($dbc, trim($_REQUEST['email']));
} else {
$email = "No Email Entered";
$errors = $errors."<p>You did not enter your email.</p>";
}
if (!empty($_REQUEST['pass'])) {
$pass = mysqli_real_escape_string($dbc, trim($_REQUEST['pass']));
} else {
$pass = "No Password Entered";
$errors = $errors."<p>You did not enter your password.</p>";
}
if ($errors == "") {
// if there were no errors, then check for the user info
//write the query selexting a record that matches the email and password fields
$q = "SELECT userid FROM makeupusers WHERE(email='$email' AND pass='$pass')";
//run the query
$r = @mysqli_query($dbc, $q);
//check how many rows were returned
$num = @mysqli_num_rows($r);
//checking if the match was made...
if ($num >=1) {
//if I logged in ok...set the session variable information
//start the session
session_save_path('/tmp');
session_start();
//set a value for logged_in to their username - to check on other pages
//NOTE: logged_in is just a variable that is made up. THIS is what is checked to see if you logged in ok..
//You might want to change the variable name for each site you create for better security
$_SESSION['makeup_login'] = "TRUE";
//redirect to the first page I want the to see.
header("Location:makeupsearch.php");
} else {
//Invalid email address/passwprd combination - not in the database
echo '<h1>Error!</h1>
<p class="afterheading">The email address and password do no match those on file. Please try again.</p>';
}
} else {
echo $errors;
}
}//end of form processing part
?>
<form id="form1" name="form1" method="post" action="login.php" >
<h1>Sign In</h1>
<p class="afterheading">Please enter your information below. <br />
Not a member? Click here to <a href="register.php">Register</a>.</p>
<table width="500" border="0" cellpadding="5" >
<tr><!--row one-->
<td width="75">Email:</td>
<td width="399">
<input type="text" name="email" id="email"
value="<?php if (isset($POST['email'])) echo $POST['email']; ?>" />
</td>
</tr>
<tr><!--row two-->
<td>Password:</td>
<td>
<input type="password" name="pass" id="pass"/>
</td>
</tr>
<tr><!--row three-->
<td></td>
<td>
<input type="submit" name="button" id="button" value="Submit" />
<input type="hidden" name="submitted" value="TRUE" />
</td>
</tr>
</table>
</form>
</div><!--end main-->
<div id="rightnav">
<img src="tips.jpg" />
</div><!--end rightnav-->
</div><!--end content-->
<?php
include ('footer.php');
?>
</body>
</html>