ASP Data Collection Forms- VB Script
Author: JoJo
Author's Site: Webade
Reference ID: 15623
Adding the VB Script into the Form Page
OK time to move on into the source code, it doesn't matter if you don't
know any scripting this is very easy!
<%@LANGUAGE="VBSCRIPT"%> <% fromName="Webade.co.uk" fromAddress="form@webade.co.uk" toName="Design" toAddress="webmaster@webade.co.uk" subject="Website Feedback Form" relay="smtp.yourhost.net" %> <html>
The code above should be placed above your opening <html> tag
as in the example, I'm sure by looking at it you can see what each line
is and its function. I'll run through them anyway.
<%@LANGUAGE="VBSCRIPT"%>
Declares the use of VB Script
fromName="Webade.co.uk" this
shows where the mail has come from
fromAddress="form@webade.co.uk"
gives the sending e-mail address
toName="Design" Supplies a friendly
name
toAddress="webmaster@webade.co.uk"
The to address dictates where the mail will be sent
subject="Website Feedback Form"
Provides the subject header for the mail
relay="smtp.yourhost.net" Provides
information of the mail relay, you may need to speak to your host for
this information.
Add the code to your page!
Hidden Fields
We now need to place six hidden fields within our form on our form.asp
page, each of these fields will hold data corresponding to the information
we have just coded into our page. Their job will be to pass that information
on to our form_response.asp page which will allow the form data to be
processed and sent.
Now we need to open the form.asp page in design view if you have closed
it, and click inside the form. I generally do this below the submit
and reset buttons but it doesn't really matter. Remember to insert six
hidden fields for the send data and while we are here we will add a
seventh hidden field to help organise our returned data.
We must now set the information for each one in the property inspector,
we do this by selecting each in turn and giving them specific names.
We will select the first hidden field and set its attributes as below.
We have given the hidden field a name of mail-relay
and a value of <%=relay%>, the Value
which is VBScript is calling for the value we gave it in the code we
wrote above the opening <html> tag.
All the hidden fields will do this, we must set each one to call for
its respective information.
We now need to repeat this for the five remaining fields that are going
to be used in sending the mail, the seventh field we'll look at when
we have completed that.
HiddenField Name |
Value |
mail-subject |
<%=subject%> |
mail-toaddress |
<%=toAddress%> |
mail-to |
<%=toName%> |
mail-fromaddress |
<%=fromAddress%> |
mail-from |
<%=fromName%> |
The Seventh Field
The seventh field is little more than a heading to insert into the
return e-mail, I find it useful with long and more complex forms but
it will do no harm to use one in this tutorial.
We select the hidden form field by clicking on it, give it a name in
the PI as above; in this instance the name is feedback.
On this occasion we have added a value to the hidden field and that
value is: :: Feedback on the web site ::
we can place this hidden field to appear anywhere we want in the returned
information and use it is as a separator. On a more complex form I would
use several of these "separators" to break the returned data
down into titled sections, creating blocks of information that are relevant
to each other.
That completes all the work for the form.asp page, that wasn't too
bad, was it?
|