Need help with Redirect

Why doesn’t this code work…


<?php
	// Access Constants.
	require_once('config/config.inc.php');
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
   <!-- ################## DEBBIE ##################### -->
   <!-- HTML Metadata -->
   <title>Double Dee, Inc.</title>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

   <!-- Page Stylesheets -->
   <link type="text/css" rel="stylesheet" href="css/_main.css" />
   <link type="text/css" rel="stylesheet" href="css/_layout.css" />
   <link type="text/css" rel="stylesheet" href="css/top_menu.css" />
   <link type="text/css" rel="stylesheet" href="css/components.css" />
</head>

<body>
  <div id="pageWrapper" class="clearfix">
    <div id="pageInner">
         <!-- BODY HEADER -->
		</div>
	</div>
</body>
</html>
<?php
	header("Location: " . BASE_URL . "/index.php");
?>

Debbie

Headers must be sent before content.

Content is any HTML

If you send any HTML - like you did by sending an entire webpage - headers are invalid. Thus they won’t work.

The scenario I posted won’t even result in an error message like “Headers Already Sent”??

Debbie

You may have display_errors set to OFF in your php.ini

You should have seen something along the lines of:


Warning: Cannot modify header information - headers already sent by (output started at /Path/to/your/file.php:29) in /Path/to/your/file.php on line 30

Or there could be an error higher up the chain which makes it never get there.