View Full Version : php header warning help please

08-28-2008, 10:35 PM
Warning: Cannot modify header information - headers already sent by (output started at D:\XAMPP\xampp\htdocs\freshandfunky\logout.php:3) in D:\XAMPP\xampp\htdocs\freshandfunky\logout.php on line 8

this is my file:

<?php session_start(); ?>

echo "You are now logged out, " . $_SESSION['user'] . ". <br /> We'll see you next time!";

$_SESSION['loggedIn'] = "false";

header("Location: index.php");


thanks for any help

08-28-2008, 10:48 PM
Take a look at ob_start:
Also make sure that your code in the head part of the document.

08-29-2008, 02:35 AM
Nile, is it possible to display time in the title of the HTML page with PHP?


08-29-2008, 04:26 AM
Cool thanks nile i read up a little on that link you posted then did a little research on headers and i got it working exactly how i want it now. thanks for the help!

08-29-2008, 04:55 AM
Nile, is it possible to display time in the title of the HTML page with PHP?


$time = date("h:i:s A");
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<title><?php print "Current Time is {$time}"; ?></title>
<style type="text/css">

<script type="text/javascript">

<div>Setting the Page Title using PHP</div>

08-29-2008, 03:47 PM
http://dynamicdrive.com/forums/showpost.php?p=158839&postcount=1337 — 4.1, 4.2. Solving 4.1 will fix your problem. Output buffering is overkill in this particular instance.

You are not allowed to change the headers after sending output, due to the way HTTP data is structured.

08-29-2008, 05:41 PM
ok i changed my code to this and works fine now:

header("location: index.php");

$_SESSION['loggedIn'] = "false";


do you think i should just session_destroy() instead of setting the login to false? would it be safer?