Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7443949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:24:51+00:00 2026-05-29T11:24:51+00:00

I am getting the Warning: Cannot modify header information . I am NOT getting

  • 0

I am getting the Warning: Cannot modify header information. I am NOT getting this error when testing the source code on WAMP. Also in some of the PHP certain classes are included and functions to manipulate the html are called as needed. Can any one point me in the right direction? Here’s the exact error and the cited files.

Warning: Cannot modify header information – headers already sent by
(output started at
/home/content/39/8810539/html/pagoda/view/header.php:2) in
/home/content/39/8810539/html/pagoda/controller/login.php on line 9

login.php:

<?php

    global $session;
    global $view;

    if (isset($_POST['login']))
    {
        if ($session->logIn($_POST["uname"],$_POST["password"]))
            header("Location: $_SERVER[REQUEST_URI]");
        else
            $view->RenderMsg("Your username and/or password was incorrect.");
    }
    if (isset($_POST['logout']))
    {
        $session->logOut();
        header("Location: $_SERVER[REQUEST_URI]"); 
    }


?>

header.php snippet:

<head>
<link rel="stylesheet" type="text/css" href="<?php echo BASEPATH; ?>/view/css/homepageStyle.css" />
</head>
<div id="header">
    <div id="banner">
        Pagoda
    </div>
    <div id="login">

<?php 

    //This controls the login/logout header on the top of each page.

    global $session;
    if ($session->isLoggedIn())
    {
?>
    <div id="nametag">
        <form method="POST" name="logout" action="">
        Welcome, <?php echo $session->getName()." (".$session->getRole().")"?>
        <input name="logout" type="hidden" value="Log Out"/>
        </form>
    </div>  
    ....
    ....
    ....
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T11:24:53+00:00Added an answer on May 29, 2026 at 11:24 am

    I solved it with ob_start(). ob_start writes the html to a buffer first, then it writes it to the browser after the header has changed. ob_start goes before your html code. It’s not necessary but good practice to close the buffer after the header() with ob_end_flush();

    header.php snippet:

    <?php
         ob_start()
     ?>
    
    <head>
    <link rel="stylesheet" type="text/css" href="<?php echo BASEPATH; ?>/view/css/homepageStyle.css" />
    </head>
    <div id="header">
        <div id="banner">
            Pagoda
        </div>
        <div id="login">
    
    <?php 
    
        //This controls the login/logout header on the top of each page.
    
        global $session;
        if ($session->isLoggedIn())
        {
    ?>
        <div id="nametag">
            <form method="POST" name="logout" action="">
            Welcome, <?php echo $session->getName()." (".$session->getRole().")"?>
            <input name="logout" type="hidden" value="Log Out"/>
            </form>
        </div>  
        ....
        ....
        ....
    

    login.php

    <?php
    
        global $session;
        global $view;
    
        if (isset($_POST['login']))
        {
            if ($session->logIn($_POST["uname"],$_POST["password"]))
                header("Location: $_SERVER[REQUEST_URI]");
                ob_end_flush();
            else
                $view->RenderMsg("Your username and/or password was incorrect.");
        }
        if (isset($_POST['logout']))
        {
            $session->logOut();
            header("Location: $_SERVER[REQUEST_URI]");
            ob_end_flush(); 
        }
    
    
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Getting the following error: "Warning: Cannot modify header information - headers already sent by
When running my script, I am getting several errors like this: Warning: Cannot modify
I'm using set_cookie() on a site. After adding some functionality, I'm getting Warning: Cannot
I keep getting 'warning: control reaches end of non-void function' with this code: -
So I keep getting this annoying error on multiple servers(its a warning, so I'd
I am getting Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource
I am getting this warning: Use of uninitialized value in eval \string\ at myscript.pl
I am getting this warning from FxCop: 'RestartForm' contains field 'RestartForm.done' that is of
I'm getting a warning: Return makes pointer from integer without a cast for this
I keep getting this as a warning I want to avoid getting this warning

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.