MailPost can save the results of a form submission in just about any format you want by using a template file. In this example, MailPost will save the information in a way that allows you to create a guestbook for your website.
The following actions were taken to produce the result:
To: From: mailpost@mcenter.com Subject: Guestbook test X-SaveAs: my-book.html X-SaveUsing: guestbook.txt This is a test of creating a Guestbook.
*noHTML* <HR> On [*date-time*], [required-name] <A HREF="mailto:[email]></A> from [$REMOTE_ADDR] wrote:
[required-comments]
Notice that we are placing form variables (denoted by the variable name surrounded by brackets) and system variables, as well as HTML codes, since this template will be used to write to an HTML file (my-book.html).
The trick to get this to work as a Guestbook is to first create the my-book.html file with either notepad, or any HTML editor you want to. When the form is processed, MailPost is going to append the information that it formats using the guestbook.txt file to the end of the my-book.file. Because of this, you have to remove the </BODY> and </HTML> tags at the end of the my-book.html file after you first create it. This lets MailPost append the new guestbook info to the HTML file. Although it's not correct HTML code (since there are no closing </BODY> or </HTML> tags) it should not cause a problem for most browsers. If you ever edit your guestbook HTML file with an HTML editor, make sure that you remove the </BODY> and </HTML> tags it may add to the end when you save it.
Also notice the special MailPost tag *noHTML* , which is the first line of the SaveUsing template file. This tag has to be on the very first line of the SaveUsing template file, and it must be the only thing on that line.
When MailPost encounters the *noHTML* tag in the SaveUsing template
file, MailPost will convert all HTML code received in a form variable to
printable characters.
Security alert!! Guestbooks
can be security problems if people are allowed to include HTML statements
in their messages. In order to provide better security, it is suggested
that you insert the *noHTML* tag in any SaveUsing template file that will
be displayed in an HTML document.