ASP Tip : Fast Form Processing
Introduction
Classic ASP came with several
tools that aren't used very much. One of these tools was the ProcessForm tool.
This allowed you to process a form quickly and save the results as a text
file.
The Template
You first need a template, this file
defines the layout of the output.
Form Information :<p>
Name : <%% Response.Write(Request.Form("fname") & " " &
Request.Form("lname")) %%> |
Save this file as 'template.asp'
Note the <%% and %%> instead of <% and %>
This template will be used to display for form
results ie. print the first and last names of the person who entered in the
form.
Processing the Form
On your form processing page you do this (the
page that the form is posting/getting to) -
<%
Set utils = Server.CreateObject("MSWC.Tools")
utils.ProcessForm "data.html", "template.asp"
%> |
This will create the file data.html and insert
the form information based on the template.
Warning! The Tools component will not
append to a file, it will overwrite it, to help stop this you can create
something like this -
<%
Set utils = Server.CreateObject("MSWC.Tools")
filenum = utils.Random
utils.ProcessForm "data." & filenum & ".html , "template.asp"
%> |
This will generate a random number (ie.
data.512.html), this will help stop it from overwriting files. Another way
would be to put a counter component as an application object and have it
generate the number.