On this page ...
Forms by E-Mail
Many commercial websites use them:
FORMS. Forms are used for questionairs, ordering, etc. Often you
need to write a script for this in handling script using (for example)
ASP, PHP, etc.
Creating a Form is not that hard,
but wouldn't it be handy if we could just e-mail the result ? This
would save us from creating scripts for handling the information
on the server where your website is placed.
For a beginner this can be hard,
but also: most providers do not support this feature on their server.
|
 |
Let's start by creating a form
For the purpose of example, let's say we
want to collect information about a PC order. We'll keep this example
resticted to say the CPU-type the users wants to order. One can extend
this ofcourse using fields like memeory, harddisk, case-type, etc.
<FORM METHOD="post"
ENCTYPE="text/plain" ACTION="mailto:email@somewhere.com?subject=subject">
In this line of HTML-code we tell the browser
that we start using a FORM of type (ENCTYPE = Encoding Type) "text/plain"
so that we humans can read the results.
The required ACTION should be sending the
result by e-mail to email@somewhere.com with subject "subject".
For another example of the e-mail tag you can take a look at the E-Mail
link page.
Options
Now we must offer the user an option,
we will be using a dropdownbox for this example, but this can be a field
or radiobox too:
<SELECT NAME="CPU">
<OPTION> 386 </OPTION>
<OPTION> 486 </OPTION>
<OPTION> Intel Pentium </OPTION>
<OPTION> Intel Pentium II </OPTION>
<OPTION> Intel Pentium Celeron </OPTION>
<OPTION> Intel Pentium III </OPTION>
<OPTION> AMD K6 </OPTION>
<OPTION> AMD K6 II </OPTION>
<OPTION> AMD Athlon </OPTION>
<OPTION> AMD Duron </OPTION>
</SELECT>
Again in HTML, we tell the browser hat this is
a selection (SELECT) of predefined values. Each option starts with the
<OPTION> tag and is to be finished with the end-option-tag: </OPTION>.
The entered value should be placed after this word: "CPU".
The selection should be completed with an end-select-tag: </SELECT>.
More of these values can be added, in this example however we stick to
just one field.
Submit = Send
After adding all these field we need to add a "Submit"
button. In HTML-code this shows as:
<input type="submit"
name="" value="Submit order">
The form will now be completed by indicating the
end of the form using </FORM>
tag.
The sample code in action:
Suppose we selected "Intel Pentium Celeron"
here, then the content of the received e-mail message will look like this:
CPU=Intel Pentium Celeron
|