Downloads |
---|
7951.zip |
I occasionally have to build a Web site, an experience that is always humbling. My problem is that I don't do Web work often enough to build any real expertise, and the time between my Web adventures is usually long enough that I forget everything I learned on the previous project. Fortunately, HTML tags simplify Web work. And even if you forget the tags, you can use Microsoft Word or Microsoft FrontPage to handle them. But gathering information from forms for use on a Web page is a hassle.
I don't want to learn Perl or any other Common Gateway Interface (CGI) programming tool to handle forms. I maxed out at 20 programming and macro languages, and I refuse to learn any more. I usually let FrontPage's built-in form bot handle the forms. Although FrontPage is a good program, getting FrontPage's Internet Information Server (IIS) extensions to work is difficult. Even FrontPage 2000's form bot is rather fragile. Downloading and installing the FrontPage 2000 IIS extensions is a challenge. As I performed this task, I worried about disaster recovery—did I want to add a step to rebuilding my Web server? I wanted to avoid using the extensions, so I searched for a way to easily collect and store form information without using heavy-duty programming. Then I remembered Active Server Pages. ASP lets you use VBScript to build server-side Web-based applications. VBScript, a variant of Visual Basic (VB), is ideal for occasional programmers.
The Task
I needed to collect comments and stories about software bugs that readers had submitted to my Software Conspiracy Web site (http://www.softwareconspiracy.com). I wanted the ASP script to collect three identification fields (name, telephone number, and email address) and a comment field, surround each field with double quotes, put commas between the fields for ease of importing to programs such as Microsoft Excel or Microsoft Access, and append the new information to an ASCII file called feedback.txt.
I feared that the project might be time-consuming, but it took only about an hour and a half. For illustrative purposes, I've summarized only the program's essentials. To save space, my example doesn't include error-handling code. You might find this example useful on your next Web project that involves forms.
In the example, I display a simple form that asks for a user's name and email address. When the user submits this information, ASP shows the information to the user and stores it in feedback.txt.
In my project, I used three files: the HTML file with the form (form.html), the ASP file to collect the data and write it out (addtext.asp), and the file to write the data to (feedback.txt). The HTML file looked like the following file:
<form method="POST" action="addtext.asp"><BR> <p>Name<input type="text" size="35" maxlength="256" name="Username"></p><BR> <p>Email<input type="text" size="35" maxlength="256" name="UserEmail"></p><BR> <p><input type="submit" value="Submit Info"> <input type="reset" value="Clear Form"></p><BR> </form>
The HTML