Different versions of different browsers use different headers or variants
of headers to decide how to fill in the file name prompt.
You may even want to make the URL that the form ACTION points to be:
ACTION=whatever.php/export.csv
So that the really dumb browsers will think they are accessing a file named
export.csv
PHP and Apache will ignore it.
As far as why to get the FORM HTML in there rather than the CSV data, I can
only guess that you have other if () clauses earlier in the script that are
messing up what goes into $FinalContent.
--
WARNING [EMAIL PROTECTED] address is an endangered species -- Use
[EMAIL PROTECTED]
Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm
----- Original Message -----
From: Jonathan Hilgeman <[EMAIL PROTECTED]>
Newsgroups: php.general
To: <[EMAIL PROTECTED]>
Sent: Wednesday, September 05, 2001 5:20 PM
Subject: Now Here's a Winner
> Okay, this has gone over my head. I am running Apache 1.3.19, with PHP
4.0.5
> and mySQL 3.23.37. The Apache/PHP server is on a Windows development box,
> and the mySQL is on a remote box. The basic function of the script is to
> first present a form where a user can select records that match a date,
and
> then they can choose whether to have the records be displayed on-screen,
or
> be sent as a file.
>
> Now, on-screen works beautifully. But, if I try the following code and
> specify to send as a file:
>
> if($ExportTo == "display")
> {
> print $FinalContent;
> }
> elseif($ExportTo == "file")
> {
> $FileName = "export-$RecordDay-$RecordMonth-$RecordYear.csv";
> Header("Content-Type: application/x-octet-stream");
> Header("Content-Disposition: attachment; filename=$FileName");
> print $FinalContent;
> exit;
> }
>
> - I get the popup window asking if I want to save it or open it. But the
> filename is not export-date.csv like it should be. Furthermore, if I
choose
> to save the file and then open it in a text editor, what I see is not
> $FinalContents, which is the expected output, but instead I see the form
> that I just submitted FROM. Yes, it saves the exact page I'm looking at -
> the one with the submit button I just pushed.
>
> Now, I know that it is getting to those Header() tags because they are the
> only ones in the code. So it is going inside the elseif() block. It is
> confusing the heck out of me.
>
> - Jonathan
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]