I have run into a problem where using the header() function and an IE6 browser client is causing my page to be requested twice. The problem is that I do a db insert everytime this page is loaded and now I am getting duplicate entries when a user is using the IE6 browser. I checked my Apache access log and I see that the page is being requested twice. I have confirmed that the multiple page loads do not happen when the user uses Mozilla or Netscape 6 as the browser. I have not checked other IE versions yet.
Here's the code:
<?php
//Display research report
require_once('baseincludes.php');
session_start();
validCustomerUse();
//create short names for variables
$reportid = trim($_GET['reportid']);
$userid = $_SESSION['userid'];
if (empty($reportid) || empty($userid) )
{
echo 'Error: Unable to display report<br>';
}
else
{
$result = retrieveReportData($reportid, $userid);
if ($result->isError())
{
echo $result->resultString();
}
else
{
$rowObject = $result->resultObject();
header("Status: 200");
header("Content-type: application/pdf"."\r\n");
echo $rowObject->report_file;
}
}
exit;
?>
If I comment out the header() lines, the problem with the duplicate page loads goes away. Not sure what I am doing wrong here. Any ideas?
Scott