473,569 Members | 2,428 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.
Jul 17 '05 #1
2 2314
mike wrote:
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...."
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 ...".
5)Excel File is sent to user's PC.

--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Jul 17 '05 #2
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" <mi**@dogstar1. com> napisal w wiadomosci
news:80******** *************** ***@posting.goo gle.com...
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.

Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3194
by: Thomas Kemmerich | last post by:
hi, i'm looking for a possibility to start a download. here is my current code: header("Content-Type: $_contenttype"); header("Content-Disposition: attachment; filename=\"$_filename\""); // flush();
10
9327
by: Bob Garbados | last post by:
forgive my ignorance, as I'm new to php coming from a ms background... If I create a page named redirect.php and it's only content is: <?php header("Location: http://www.google.com"); ?> Should it not redirect to www.google.com? I can't get the header() function to redirect. I'm trying to take an online reservation... the customer...
30
4819
by: Anon | last post by:
If Http headers specify the character encoding, what is the point of the Meta tag specifying it?
11
2738
by: Steven T. Hatton | last post by:
In the past there have been lengthy discussiions regarding the role of header files in C++. People have been very adamat about header files serving as in interface to the implementation. I do understand the objective. This example may represent an interface in need of a bit of refactoring, but it goes to demonstrate the basic idea as I...
2
2668
by: Whitney | last post by:
I've been going bonkers trying to find the answer to this question... I'm hoping somebody out there can help me. Our network environment is Active Directory and our web server is Windows 2003 IIS 6. I've got an ASP page that we include into each of our pages to act as our companywide header. We force users to authenticate into our...
11
8316
by: Peter Wu | last post by:
Hello, I want to create a Header and Footer for every ASPX page I build. I created 2 Web user controls respectively and placed them in an ASPX page. The problem is that I cannot position the Footer to be always at the bottom of the page. The Header and Footer are always together at the top of the page. Was I missing anything? Thanks!
10
2438
by: universalbitmapper | last post by:
Hi, I'm trying a simple form.html that call a .html script that begins with: <?php header("This is a test"); ?> When I click on the link, I get blank page.
1
4799
by: AndrewF | last post by:
Hi all, I am sure something like this has been covered somewhere so I am hoping a quick answer or pointer may suffice, however a couple of days trawling and I can't find anything on it. I'm building a layout and for reasons of PDA and text based browsers I want to have my primary navigation at the bottom of the HTML layout. Thus the main...
6
2303
ak1dnar
by: ak1dnar | last post by:
Hi, I am creating script to download some files using download dialog box.First time i tried to use ajax for this, but i failed. So i went through this way, By Using this function i am going to submit the Data to process to PHP. JS Function: function file_down(fid) { window.location = "download.php?fid="+fid; }
0
7703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7618
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7926
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8138
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7983
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
3657
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2117
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
946
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.