I use the following function to open a RTF document and populate it with data from the DB.
It works fine in Mozilla, but when I open ity in IE it tries to open it asa PHP file.
Is there something wrong with the headers?
function openDoc($id){
$result = runQuery("select * from documents where id = $id");
$row = mysql_fetch_array($result);
$title = stripslashes($row['title']);
$text = nl2br(stripslashes($row['text']));
$date = stripslashes($row['date']);
$name = stripslashes($row['name']);
header('Content-Type: application/vnd.msword');
// These two lines saved the day!
header('Pragma: public');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-Disposition: inline, filename=$name.rtf');
// open our template file
$filename = 'rtf/template.rtf';
$fp = fopen ( $filename, 'r' );
//read our template into a variable
$output = fread( $fp, filesize( $filename ) );
fclose ( $fp );
// replace the place holders in the template with our data
$output = str_replace( '!!title!!', strtoupper( $title ), $output );
$output = str_replace( '!!text!!', $text, $output );
$output = str_replace( '!!date!!', $date, $output );
$output = str_replace( '<br />', '\par', $output );
echo $output;
}