Jump to content

More header problems


PHPiSean

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.