Forum Moderators: coopster
<?php
session_start();
if($_SESSION['loggedIn'] != md5("loggedin")){
header("Location: login.php");
}//if
include("masterHeader.php");
$location = "Physician Education";
?>
Here is the error I am getting
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at \\intellicom05\Company\Customers\ColglazierClinic\Web\www\doctorArea\docwork.php:1) in \\intellicom05\Company\Customers\ColglazierClinic\Web\www\doctorArea\docwork.php on line 2
Warning: Cannot modify header information - headers already sent by (output started at \\intellicom05\Company\Customers\ColglazierClinic\Web\www\doctorArea\docwork.php:1) in \\intellicom05\Company\Customers\ColglazierClinic\Web\www\doctorArea\docwork.php on line 5
I have worked with sessions and headers for a long time, but I can't seem to see what I'm missing here. Thanks,
header("Location: login.php");
}//if
$location = "Physician Education";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- #BeginTemplate "patientAreaMaster.dwt" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<!-- #BeginEditable "doctitle" -->
<title>Colglazier Demmel Medical Clinic - <?php echo $location ?></title>
<!-- #EndEditable -->
<link href="../css/style3.css" rel="stylesheet" type="text/css" />
<link href="../css/style4.css" rel="stylesheet" type="text/css" />
</head>
<body>
<!-- Begin Container -->
<div id="container">
<!-- Begin Masthead -->
<div id="masthead">
<h1>Colglazier Demmel Medical Clinic</h1>
<div id="address">
945 Washington Ave<br />
PO Box 97<br />
Grant, NE 69140<br />
308.352.2122
</div>
<img src="../images/combine_wheat.jpg" alt="Sunflowers in a field" /></div>
<!-- End Masthead -->
<!-- Begin Navigation -->
<div id="navigation">
<ul>
<li><a href="../index.php">Home Page</a></li>
<li><a href="../patientArea/index.php">Patient Area</a></li>
<li><a href="../patientArea/ed.php">Patient Education</a></li>
<li><a href="../pchs/index.php">PCHS Hospital</a></li>
<li><a href="index.php">Physician Area</a></li>
<li><a href="edstart.php">Physician Education</a></li>
<li><a href="../photo_gallery.php">Photo Gallery</a></li>
<li><a href="#">Contact Us</a></li>
</ul>
</div>
<!-- End Navigation -->
<!-- Begin Content -->
<div id="content">
<!-- #BeginEditable "content" -->
<h3>Doctor Work Area - CATEGORIES</h3>
<ul>
<li><a href="#nucmed">Front Range Nuclear Medicine</a></li>
<li><a href="#pathservice">Pathology Services</a></li>
<li><a href="#pchsxray">PCHS Xray</a></li>
<li><a href="#regionwest">Regional West Medical Center</a></li>
</ul>
<h3>DocWork - Links By Category</h3>
<p><a name="nucmed">Front Range Nuclear Medicine</a></p>
<ul>
<li><a href="http://www.aphsa.org">Front Range Nuclear Medicine</a>
<br />NucMed, Bone Density
</li>
</ul>
<p><a name="pathservice">Pathology Services</a></p>
<ul>
<li><a href="http://www.aphsa.org">Pathology Services</a>
<br />Pathology for Everyone
</li>
</ul>
</ul>
<p><a name="pchsxray">PCHS Xray</a></p>
<ul>
<li><a href="http://www.aphsa.org">PCHS Xray</a>
<br />PCHS Xray
</li>
</ul>
<p><a name="regionwest">Regional West Medical Center</a></p>
<ul>
<li><a href="http://www.aphsa.org">Regional West Medical Center</a>
<br />Regional Care
</li>
</ul>
<p><a name="somthing">Something or Other</a></p>
<ul>
<li><a href="http://www.aphsa.org">Front Range Nuclear Medicine</a>
<br />NucMed, Bone Density
</li>
<li><a href="http://www.aphsa.org">American CRC</a>
<br />Nonprofit, bipartisan .
</li>
<li><a href="http://www.aphsa.org">American CRC</a>
<br />Nonprofit, bipartisan .
</li>
<li><a href="http://www.aphsa.org">American CRC</a>
<br />Nonprofit, bipartisan .
</li>
<li><a href="http://www.aphsa.org">American CRC</a>
<br />Nonprofit, bipartisan .
</li>
<li><a href="http://www.aphsa.org">American CRC</a>
<br />Nonprofit, bipartisan .
</li>
<li><a href="http://www.aphsa.org">American CRC</a>
<br />Nonprofit, bipartisan .
</li>
</ul>
</ul>
<p> </p>
<!-- #EndEditable -->
</div>
<!-- End Content -->
<!-- Begin Footer -->
<div id="footer">
<p><a href="../index.php">Home Page</a> ¦
<a href="../patientArea/index.php">Patient Area</a> ¦
<a href="../patientArea/ed.php">Patient Education</a> ¦
<a href="../pchs/index.php">PCHS Hospital</a> ¦
<a href="index.php"> Physician Area</a> ¦
<a href="edstart.php">Physician Education</a> ¦
<a href="../photo_gallery/">Photo Gallery</a> ¦
<a href="#">Contact Us</a> ¦
<?php
if($_SESSION['loggedIn'] == md5("loggedin")){
echo("<a href=\"admin.php\">Admin</a> ¦ <a href=\"logout.php\">Logout</a>");
}//if
else{
echo("<a href=\"login.php\">Login</a>");
}//else
?></p>
</div>
<!-- End Footer -->
</div>
<!-- End Container -->
</body>
<!-- #EndTemplate -->
</html>
1. You have a space or some other character in front of your <?php tag on the page. Check your page in several text editors (Notepad++, ConTEXT, regular notepad, etc.) to make sure that your current one isn't inserting something before the <?php tags for some reason.
2. Your server is, for some reason, configured to send headers before executing the PHP code. I'm not an expert on this, but if this is the case it's almost certainly an Apache or IIS configuration problem.
I ran into a very similar problem. Code seemed 100% legit. But I got errors trying to view the page. Copy-and-paste the code to a new page; voila! Page works! But the original page (with same code) did not! Exceedingly frustrating!
After hours of debugging... I noticed (in Notepad++) that my "error" page was in MAC format, while the rest of my pages were set in UNIX format (my preference). Turns out (as WesleyC indicates), my page being in MAC, on a UNIX machine, somehow managed to cause an invalid character or such that threw PHP off. I resaved the file in UNIX format (same code); problem gone.
Hopefully your issue is as simple!