• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 205
  • Last Modified:

2 content-types

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.
0
Pakfan
Asked:
Pakfan
  • 3
1 Solution
 
aioudineCommented:
here is P-code

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

  generate file(filename)

  output
      <HTML><TITLE></TITLE><BODY>
      <frameset rows="1,*" border=0>
      <frame name=wsg_top src="/cgi-bin/download.pl?filename" marginheight=0>
      <frame name=wsg_bot src="thankyou.html" marginheight=0>
      </frameset>
      </BODY></HTML>
ELSE
 output
     <HTML><TITLE></TITLE><BODY>
       Samethink wrong try again
    </BODY></HTML>
FI

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


---- download.pl script  -----
START
getvariable(filename)
output
<meta http-equiv="Refresh" content="0; url="http://site/downloaddir/filename">
END
--- end download script -----

0
 
PakfanAuthor Commented:
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.
0
 
mouattsCommented:
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.
0
 
PakfanAuthor Commented:
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.
0
 
PakfanAuthor Commented:
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";
thankyou();
success();
 
print "--Boundary\n\n";
print "Content-type: text/tab-separated-values\n\n";
success();

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

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now