I have had 3 people look at this and they are all at a loss. My code all makes perfect sense to to and all the testing for my auth_level is correct and works properly.
My problem when testing the code is that it comes out with error with my session_start(); line and my header("Location: auth2menu.php"); line.
Can Anyone help or let me know what these errors are trying to communicate?
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/oddprod/public_html/login3.php:9) in /home/oddprod/public_html/login3.php on line 11
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/oddprod/public_html/login3.php:9) in /home/oddprod/public_html/login3.php on line 11
Warning: Cannot modify header information - headers already sent by (output started at /home/oddprod/public_html/login3.php:9) in /home/oddprod/public_html/login3.php on line 47
//start sessions
session_start();
// Connect to DB
$db = mysql_connect ("localhost", "username", "password")
or die ('I cannot connect to the database because: ' . mysql_error());
$db_selected = mysql_select_db('oddprod_managment', $db);
if (!$db_selected) {
die ('Can\'t use oddprod_managment : ' . mysql_error());
}
// End Connect
//extract user information from database
if ($username && $password)
{
// if the user has just tried to log in
$query = "select * from users "
."where usersLOGIN='$username' "
." and usersPASS='$password' ";
$result = mysql_query($query);
$row = mysql_fetch_assoc($result);
if (mysql_num_rows($result) >0)
{
// if they are in the database register the user id
$_SESSION['valid_user'] = $row['usersLOGIN'];
$_SESSION['pass'] = $_POST['password'];
$_SESSION['auth_level'] = $row["usersTITLEID"];
}
}
if ($_SESSION['auth_level']==1){
header("Location: auth2menu.php");
}
else if($_SESSION['auth_level']==2){
header("Location: auth2menu.php");
}
mysql_close($db);