Connecting Tech Pros Worldwide Help | Site Map

header problem - want to display html AND download a file

mike
Guest
 
Posts: n/a
#1: Jul 17 '05
ok here's the problem:

I have a page that displays a form for user to select individual
fields and to specify their own criteria which is used to query a
database and then create an excel spreadsheet and download it to their
PC.

when the user clicks on the "create a custom query" link on the
reports page the file customss.php displays the form that list the
various fields and criteria to specify for the search. This part
works fine.

once the user clicks the button to submit the query the file
customssdisplay.php generates the Excel file and then sends it to the
client PC.

The problem is that once the user cliks the button to submit the
query, the form which displays the list of available criteria and
fields is still displayed EVEN AFTER the spreadsheet has been
downloaded to the PC.


Here's what I would like to happen is:

1)user clicks button to create the custom query

2)the form is displayed for the user to check fields for inclusion and
specify search criteria.

3)user chooses what they want and then clicks "submit query"

4)******* A page displays saying something like "Generating
report...."

5)Excel File is sent to user's PC.



OK now I've tried specifying a bit of html in the customssdisplay.php
file that generates the spreadsheet but this gives me error messages
saying that the header has already been sent. I suppose I could
create a passthrough file which creates a form with all the fields
hidden (taken from the search criteria page) but this seems cumbersome
and inefficient. I would appreciate any help that could be offered.
Pedro Graca
Guest
 
Posts: n/a
#2: Jul 17 '05

re: header problem - want to display html AND download a file


mike wrote:[color=blue]
> Here's what I would like to happen is:
>
> 1)user clicks button to create the custom query
>
> 2)the form is displayed for the user to check fields for inclusion and
> specify search criteria.
>
> 3)user chooses what they want and then clicks "submit query"
>
> 4)******* A page displays saying something like "Generating
> report...."[/color]

What about?
4) A page displays saying something like

Your document has been generated. You may <a
href="customssdisplay.php">download it</a> by right-clicking
and choosing "Save as ...".
[color=blue]
> 5)Excel File is sent to user's PC.[/color]
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Chung Leong
Guest
 
Posts: n/a
#3: Jul 17 '05

re: header problem - want to display html AND download a file


It's a bird. It's a plane. No, it's the invisible inline frame!

There's some test code:

test.php:

<html>
<body>
<p>The download will start now!</p>
<iframe src="test2.php?query=<?=$query?>" style="display: none"></iframe>
<p>Something something...</p>
</body>
</html>

test2.php:

<?

header("Content-type: application/octet-stream");
header("Content-disposition: attachment; filename=\"testing.txt\"");

echo str_repeat("Hello world\n", 1000);

?>

Uzytkownik "mike" <mike@dogstar1.com> napisal w wiadomosci
news:808dc180.0402101030.2a3b7395@posting.google.c om...[color=blue]
> ok here's the problem:
>
> I have a page that displays a form for user to select individual
> fields and to specify their own criteria which is used to query a
> database and then create an excel spreadsheet and download it to their
> PC.
>
> when the user clicks on the "create a custom query" link on the
> reports page the file customss.php displays the form that list the
> various fields and criteria to specify for the search. This part
> works fine.
>
> once the user clicks the button to submit the query the file
> customssdisplay.php generates the Excel file and then sends it to the
> client PC.
>
> The problem is that once the user cliks the button to submit the
> query, the form which displays the list of available criteria and
> fields is still displayed EVEN AFTER the spreadsheet has been
> downloaded to the PC.
>
>
> Here's what I would like to happen is:
>
> 1)user clicks button to create the custom query
>
> 2)the form is displayed for the user to check fields for inclusion and
> specify search criteria.
>
> 3)user chooses what they want and then clicks "submit query"
>
> 4)******* A page displays saying something like "Generating
> report...."
>
> 5)Excel File is sent to user's PC.
>
>
>
> OK now I've tried specifying a bit of html in the customssdisplay.php
> file that generates the spreadsheet but this gives me error messages
> saying that the header has already been sent. I suppose I could
> create a passthrough file which creates a form with all the fields
> hidden (taken from the search criteria page) but this seems cumbersome
> and inefficient. I would appreciate any help that could be offered.[/color]


Closed Thread