Jump to content

Cannot modify header information


KeithLantern

Recommended Posts

I keep getting this error Warning: Cannot modify header information - headers already sent by (output started at /home2/orangejuicea/public_html/coffeetable/logout.php:3) in /home2/orangejuicea/public_html/coffeetable/helpers/system_helper.php on line 24

I believe that something is wrong between tehse two files.  Is there anyone who can help me.  Any advice you would give would be greatly appreciated.

SYSTEM_HELPER.PHP
<?php
/*
 * Redirect To Page
*/
function redirect($page = FALSE, $message = NULL, $message_type = NULL) {
    if (is_string ($page)) {
        $location = $page;
    } else {
        $location = $_SERVER ['SCRIPT_NAME'];
    }

    //Check For Message
    if($message != NULL){
        //Set Message
        $_SESSION['message'] = $message;
    }
    //Check For Type
    if($message_type != NULL){
        //Set Message Type
        $_SESSION['message_type'] = $message_type;
    }

    //Redirect
    header ('Location: '.$location);
    exit;
}

/*
 * Display Message
 */
function displayMessage(){
    if(!empty($_SESSION['message'])) {
        
        //Assign Message Var
        $message = $_SESSION['message'];
            
        if(!empty($_SESSION['message_type'])) {
            //Assign Type Var
            $message_type = $_SESSION['message_type'];
            //Create Output
            if ($message_type == 'error') {
                echo '<div class="alert alert-danger">' . $message . '</div>';
            } else {
                echo '<div class="alert alert-success">' . $message . '</div>';
            }
        }
        //Unset Message
        unset($_SESSION['message'] );
        unset($_SESSION['message_type'] );
    } else {
        echo '';
    }
}

/*
 * Check If User Is Logged In
 */
function isLoggedIn(){
    if(isset($_SESSION['is_logged_in'])){
        return true;
    } else {
        return false;
    }
}

/*
 * Get Logged In User Info
*/
function getUser(){
    $userArray = array();
    $userArray['user_id'] = $_SESSION['user_id'];
    $userArray['username'] = $_SESSION['username'];
    $userArray['name'] = $_SESSION['name'];
    return $userArray;
}

 

 

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
HEADER.PHP
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Welcome To The Coffee Table</title>

   <!-- Bootstrap core CSS -->
    <link href="<?php echo BASE_URI; ?>templates/css/bootstrap.css" rel="stylesheet">
    <!-- Custom styles for this template -->
    <link href="<?php echo BASE_URI; ?>templates/css/custom.css" rel="stylesheet">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <script src="<?php echo BASE_URI; ?>templates/js/bootstrap.js"></script>
    <script src="<?php echo BASE_URI; ?>templates/js/ckeditor/ckeditor.js"></script>
    <?php
    //Check if title is set, if not assign it
    if(!isset($title)){
        $title = SITE_TITLE;
    }
    ?>
  </head>

  <body>

    <div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
      <div class="container">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="index.php">The Coffee Table</a>
        </div>
        <div class="collapse navbar-collapse">
          <ul class="nav navbar-nav navbar-right">
            <li class="active"><a href="index.php">Home</a></li>
            <?php if(!isLoggedIn()) : ?>
                <li><a href="register.php">Create An Account</a></li>
            <?php else : ?>
                <li><a href="create.php">Create Topic</a></li>
            <?php endif; ?>
          </ul>
        </div><!--/.nav-collapse -->
      </div>
    </div>

    <div class="container">
        <div class="row">
            <div class="col-md-8">
                <div class="main-col">
                    <div class="block">
                        <h1 class="pull-left"><?php echo $title; ?></h1>
                        <h4 class="pull-right">A simple PHP forum engine</h4>
                        <div class="clearfix"></div>
                        <hr>
                        <?php displayMessage(); ?>


 

Link to comment
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.