Optical Disc Technology  » Emailing Form Input Using ASP

Emailing Form Input Using ASP

Everybody uses online forms these days, whether to get user feedback or to get orders. They present your visitors with a means to convey their message to you.

Most of the webmasters prefer using CGI scripts for processing and emailing form inputs. Such scripts are copiously available, mostly free, at various free-scripts resources on the Net. Most of CGI happens in Perl, so you gotta be in friendly terms with the scripting language in order to fine tune the form-handling script according to your own, special needs.

A better alternative is, using either ASP or PHP. Both scripting languages are easy to use and require less coding. In Perl, if you write a routine in 50 lines, the same routine can be written, in say, 10 lines in ASP.

In this article I'm going to tell you how to write an HTML-form handling script in ASP. This script does two things - it emails you the details entered by the visitor, and then it displays a thank you page. It also checks if the user has left a relevant field, here, email, blank.

There are basically two email handling objects used by the servers supporting the ASP capability, viz., CDONTS and SMTP. We'll see how both work.

First, let us make an HTML page that contains our form (note that every HTML tag is preceded by a dot so that some of the email clients don't throw up a tantrum - you'll have to remove them before implementing the code):

"form.html"

.

.

. This is a test page to run an ASP script that handles form input.

.

.

.

....

.

.

.

And now we write the ASP file that handles the required script to process the above form. Remarks are inserted using ' .

"emailform.asp"

.

.

.

' You'll need the above command in case you want to show a "Thank you" page, as you'll need to "re-direct" to "thankyou.html".

.

.

. The form handling script.

.

.

.

I have demonstrated both CDONTS and SMTP, but you have to use only one. You'll have to ask your web host what to use.

As usual, if you have a doubt, you can write to me at amrit@bytesworth.com.

All the best.

About the Author

Amrit Hallan is a freelance web designer. For all web site

development and web promotion needs, you can get in touch with

him at http://www.bytesworth.com. For more such articles,

visit http://www.bytesworth.com/articles and

http://www.bytesworth.com/learn You can subscribe to his

newsletter [BYTESWORTH REACHOUT] on Web Designing Tips & Tricks

by sending a blank email at bytesworth-subscribe@topica.com