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
Inside Out: “Active Server Pages Takes the Bite out of Forms” (February 2000) contains an Active Server Pages (ASP) file in which some lines of code wrap across two lines of text but don’t contain a continuation character sequence ( _). A correct version of the file is available for download at http://www.win2000mag.com/articles. Enter 7951 in the InstantDoc ID text box and click on the Zip file in the Article Info box.
Did anyone else who tried this sample get the following error?
Technical Information (for support personnel)
Error Type:
Microsoft VBScript compilation (0x800A0400)
Expected statement
/addtext.asp, line 6
("Scripting.FileSystemObject")
I copied the text from the article verbatim.
I found the article very exciting because I have been trying to learn ASP for the past few weeks. I would really appreciate some clarification on this if possible.
Thank you.........I always read your magazine and learn new tricks all the time.
Mark Minasi's Inside Out: "Active Server Pages Takes the Bite out of Forms" (February 2000) is a great article. What the article describes is exactly what I want to do. Will you send me the three files you reference in the article (form.html, addtext.asp, and feedback.txt)?
--Cliff Airhart
The article incorrectly states: "ASP scripts work only on Web servers running IIS or machines running Peer Web Services (PWS) 3.0." This is not accurate. Chili!soft has a product called Chili!ASP that allows ASP scripts to run on several flavors of windows. htttp://www.chilisoft.com
This message is more for James R. Gregg. You might try the following to "clean up" your issue.
1. Make sure you end up with three files (form.html, addtext.asp and feedback.txt)
2. Place "Feedback.txt" into your C: directory, the other two into a directory in your wwwroot/inetpub folder. I placed mine in a folder named "CODE"
3. Make sure you have properly "shared" that folder for ASP purposes.
4. Access the files by typing http://localhost/CODE/form.html
5. Enjoy playing with the app.
I think your issue may have arisen out of not having your "ASP" file properly named. If you do it in notepad, you must make sure when you save your file that you select "all files" and not "text files" from the drop down box at th ebottom, otherwise your file could get saved like this 'addtext.asp.txt" which your computer will not process.
Good Luck
I, too, am very interested in this article as it describes exaclty what I require, but do not have the time (at the moment) to learn how to do it fully. However, upon running the page, despite copying exactly (at least I'm fairly sure), I get the following error:
Microsoft VBScript compilation error '800a0400'
Expected statement
/bpyoung/addtext.asp, line 14
option explicit