header problem - want to display html AND download a file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mike

    header problem - want to display html AND download a file

    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

    #2
    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="customssd isplay.php">dow nload 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 =--

    Comment

    • Chung Leong

      #3
      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=\"test ing.txt\"");

      echo str_repeat("Hel lo world\n", 1000);

      ?>

      Uzytkownik "mike" <mike@dogstar1. com> napisal w wiadomosci
      news:808dc180.0 402101030.2a3b7 395@posting.goo gle.com...[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]


      Comment

      Working...