|
The text and programs here are from the first edition of CGI Programming 101. This has been replaced by the 2nd edition; please click here to view the updated material from the 2nd edition. |
| Name | Description | |
| post.txt | Form Processor (source code) | |
| post.html | Form Example | |
| mail.txt | Form-To-Mail CGI (source code) | |
| mail.html | Form-To-Mail Example |
Here's how. In your CGI, just open the HTML file, read it, then print it back out:
open(INF,"Thanks.html"); @thanks = <INF>; close(INF); print "Content-type:text/html\n\n"; print @thanks;
How can I make my form-to-mail CGI print the variables to the email in the same order they were entered on the form?
You'll find that if you use the above form-to-mail CGI, which does a
foreach $key (keys(%FORM)) to print the form values, you'll
get the values in random order. To print them in the order they
appear on the form, you can add this line to the form-decoding block:
push(@keys, $name);Then you'll change your foreach line to
foreach $key (@keys).
Here is the full source code showing how to do this:
| mail2.txt | Form-To-Mail CGI (source code) (sorted output) |