PHPiSean Posted February 16, 2011 Share Posted February 16, 2011 Hello, I have read the READ BEFORE POSTING about the headers, and that doesn't seem to answer my problem. I have 2 if statements in included files that have header statements with location. I don't understand why I am still getting the header error (Warning: Cannot modify header information) if I have my headers in if statements. Take a look home.php <?php require("header.php"); require("isadmin.php"); ?> header.php <?php session_start(); require_once("includes/dbconn.php"); if($_SESSION['username']) { echo "Welcome ". $_SESSION['username']; }else{ header("Location: login.php"); } $session = $_SESSION['username']; $logout = "<a href='safelogout.php'>Log Out</a>"; echo $logout; ?> <title>Website</title> isadmin.php <?php mysql_select_db('center'); $session = $_SESSION['username']; $sql = "select * from users where username='$session'"; $result = mysql_query($sql); $row = mysql_fetch_array($result); $perm = $row['permission']; if($perm == 2) { header("Location: admin/home.php"); } ?> Link to comment https://forums.phpfreaks.com/topic/227824-more-header-problems/ Share on other sites More sharing options...
Pikachu2000 Posted February 16, 2011 Share Posted February 16, 2011 The error message will tell you exactly where the output started. Link to comment https://forums.phpfreaks.com/topic/227824-more-header-problems/#findComment-1174817 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.