The ".asp" extension is very important and not adding it is the main cause of these tutorials not giving people the effect they're looking for. Here are the files:
Again, just to drive a point home, copy and paste the code and save it with an ".asp" extension.
Right now the form is just two text boxes named yourname and email, a couple of radio buttons named answer, and a submit button.
Yes, you will be able to add and alter the items that make up the Guestbook page, but right now let's stay on track.
Notice This!
Did you see that there was some bold text when you copied and pasted? The bold text was the ASP page the ACTION attribute pointed to. It looked like this:
See it? In terms of this Guestbook page, that's really the only the thing you have to be concerned with. Right now the ACTION is set to send the output of the form to the thank-you page, asp_ty.asp.
If you kept the name intact and you named your thank-you page asp_ty.asp, they you don't have to change a thing -- it's ready to roll. But if you did change the name of the thank-you page, you need to change this out to read whatever name you chose.
Moving along...
Here's the first line of code that really involves what the user entered into the Guestbook form page:
See the command within the < and >. That's VBScript that posts what was written in the text box given the name yourname. Remember that format. It's going to come into play again later.
Remember that this is ASP. That code will never be seen by the user, even if they look at the source. It'll just simply read Thanks for filling out the form, Bill.. That is, if some guy named Bill answered the form. Following the concept here?
Set Up The E-Mail
The next small block of code sets up destination and originating variables plus a subject line and body so that the text has somewhere to go. Don't touch it. I'm just pointing out what it does. No need to mess with it.
Fill the Variables
Now we're at a point where you have to alter the code a bit.
OriginatingEmail = Request.form("email")
DestinationEmail = "you@email.com"
Subject = "The Subject Line Goes Here"
The first line is good to go. It's using the input the user entered in the text box named email. Don't touch it.
The next two lines require you to put in your own e-mail, or the e-mail address where you want the mail to end up, then a subject line. Do that.
The Body of the E-Mail...
...is created by the next little block of code. Notice the format. It's much like the first code we talked about that posts the user's name to the page. All this line of code does is take the text in the two text boxes, and the user's choice between the radio buttons, and make it one line of text.
Notice the format. Each blurb or code starts with an "&" and ends with a semicolon. That will become important to you later when you want to add additional elements.
Send that Mail!
The next blurb of code sends the mail. I have mentioned that the mail element has to be added to the server for this format to run. I only put that in, in case the form doesn't run. I would be very, very surprised if your ASP server didn't have the mail utility installed.
Did the Mail Send?
Those of you who know JavaScript will basically pick this next set of code lines apart right off. It's a conditional statement. If the mail failed to send, the text "Failed to send form results to" appears on the page along with the address that was supposed to get the mail and the reason why the mail send failed. But if the mail went, you get the message "Your form Results have been sent".
Very clever. I think this is the greatest part of this whole Guestbook system.
Respond to the User
The final block of text is, again, a conditional statement that displays text depending on which radio button the user chooses. If the user chooses the radio button with the VALUE "yes", then the text "I like Active Server Pages Too!" is written to the page. If the user chooses the radio button with the VALUE "no", then the text "I don't like Active Server Pages either!" writes to the page.
Again, this all happens behind the scenes. The user will never actually see the VBScript code. When the page is displayed, all of this will be replaced with simple text. The source code will look like a basic HTML document. Neat, huh?
<%=Request.form("######")%>
So, now you can add as many text boxes and text area boxes as you'd like to. Just remember to give each text element a different name. Then you can take and place the text the user put into the text element simply by following the format above and putting the NAME you gave the text element in where I have "######". Easy.
If you want to add what the user put in the text element into the e-mail message that comes to your mailbox, simply follow the format that was used to create the Body section of the text. Each new element begins with an "&" and ends with a semicolon. Watch the quotes, too.
Want to add another couple of radio button, check box, or pull-down box choices and have something write to the page depending on the choice? Follow the format in the last block of code to get the effect. Just remember to give each element a VALUE. That's what is used to determine what choice the user made.
Enjoy!