2 content-types

Posted on 1998-11-09
Last Modified: 2013-12-25
I need 2 things to happen in my CGI:
  First: if the user successfully fills in the fields, they will be prompted where to save a tab-delimited file. This is done by Content-type: text/tab-separated-values
  Second: if the user successfully fills in the fields, they will get a confirmatory thank-you message via Content-type: text/html
Of course, if they were not successful, they will get a text/html error message. The question is: how do you get 2 content-types to work together? Kind of like when you download a Netscape product. After you select a path to download it, you get a Thank-You message.
Question by:Pakfan
  • 3

Expert Comment

ID: 1829489
here is P-code

------- main script ------
IF good_input

  generate file(filename)

      <frameset rows="1,*" border=0>
      <frame name=wsg_top src="/cgi-bin/" marginheight=0>
      <frame name=wsg_bot src="thankyou.html" marginheight=0>
       Samethink wrong try again

--- end main script ------

---- script  -----
<meta http-equiv="Refresh" content="0; url="http://site/downloaddir/filename">
--- end download script -----


Author Comment

ID: 1829490
That does not help. I need somthing more generic. The proposed anser will not fit my needs. The simple theory of how to tackle multiple content-types would help, however. I am not using frames and the tab-separated file is one the user generates based upon what they enter in the form.
LVL 11

Accepted Solution

mouatts earned 150 total points
ID: 1829491
You can use multipart content type I did have an example but I can't find it. As an alternative you could transmit your thank you page first with a refresh on it which points to the URL that will force the download of you tab seperated file. This way the thank you page and the download will occur more or less at the same time.

Author Comment

ID: 1829492
I guess I should mention that like the tab-separated file, the Thank-you message is also based on user input. It will contain the contents of the tab-separated file ie. it will say something like "Thank you, this is the contents of the file you saved: ...". Hence, it cannot be a static HTML page. It must be part of the script. Feel free to use some Perl code if you think that will help.

Author Comment

ID: 1829493
Ok, since this seems to be a more difficult question than originally intended, I am providing more details. Here is the main part of the Perl script:

#print "HTTP/1.0 200\n";                             # Tried this with and without the comment
print "Content-type: multipart/mixed;boundary=\"Boundary\"\n\n"; # tried this with                                                                                                                                                                                                                             # x-mixed-replace as well.

print "--Boundary\n\n";
print "Content-type: text/html\n\n";
print "--Boundary\n\n";
print "Content-type: text/tab-separated-values\n\n";

print "--Boundary--\n\n";


Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
Introduction This tutorial will give you a fast look what you can do with WhizBase. I expect you already know how to work with HTML at least, and that you understand the basics of the internet and how the internet works. WhizBase is a server-s…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now