Jump to content

Cannot modify header information


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.

 * 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;

    header ('Location: '.$location);

 * 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(){
        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;



<!DOCTYPE html>
<html lang="en">
    <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>
    //Check if title is set, if not assign it
        $title = SITE_TITLE;


    <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>
          <a class="navbar-brand" href="index.php">The Coffee Table</a>
        <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; ?>
        </div><!--/.nav-collapse -->

    <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>
                        <?php displayMessage(); ?>


Link to comment
Share on other sites


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.