Now Here's a Winner

From: Date: Wed, 05 Sep 2001 22:20:29 +0000
Subject: Now Here's a Winner
Groups: php.general 
Request: Send a blank email to php-general+get-66117@lists.php.net to get a copy of this message
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

« previous php.general (#66117) next »