Having a problem with 'Warning: Cannot modify header information - headers already sent'
I have checked the search facility on these boards and found out what the problem is, have amended it as much as I can, but still cannot get the code to work.
Brief outline of what I am trying to do - user logs in on login page - this form directs to page authority.php (the code with the error), based on the login name I check in the database to see what password authority level they have been assigned and based on this level 1-4 I send them to the appropriate page......
code for page authority.php
session_start();
$_SESSION['username'] = $username;
require_once ('../mysql_connect.php');
$query = "SELECT `AuthorityLevel` FROM `tblUser` WHERE `CLogIn` = '$username'";
$result = mysql_query($query)
or die(mysql_error());
$row = mysql_fetch_array($result);
$AuthorityLevel = $row["AuthorityLevel"];
if ($AuthorityLevel = 1){header("Location: level1.php");}
elseif ($AuthorityLevel = 2){header("Location: level2.php");}
elseif ($AuthorityLevel = 3){header("Location: level3.php");}
else{header("Location: level4.php");}
I have taken out all the blank space I can find - there is no blank space prior to <?php tag - this is why the code looks so cramped, I took out all the space just to be safe!
The error message give the line where the output started as the line require_once ('../mysql_connect.php');
but I have to be connect to the database to query it and get the results to do the if / else bit of code.
Again, searching these boards, I have seen codes suggested that look similar so I really don't know where i am going wrong......how else I can achieve this........
any ideas will be gratefully received.