I have this section at the end of a page
-------------------
if ($_POST['assign']== 'Open in Excel'){
if (empty($data)) {
$data = "\n(0) Records Found!\n";}
header("Content-type: application/xmsdownload");
header("Content-Disposition: attachment; filename=".
$file_name.date("Y:m:d H:i").".xls");
header("Pragma: no-cache");
header("Expires; 0");
print "$header\n$data";
exit;
}else{
include "header.php";
include $template_path.$template;
include "footer.php";
}
Because the header.php is sent at the bottom of the page I can't have
the print to Excel output header in the if statement or I get the
message header already sent. I need the else statements where they
are because earlier in the code there are different selections of
templates depending on if a form is filled out so at the end it has to
display the right template.
Is there a way to send the excel output away from the page in a
function or something so that it processes the else?
thanks,