Week 5 - October 17th 2006


Forms are always two parts, the actualy form that users see, and the back end coding that sends that code in a usuable format to the owser of the site. This class will only teach how to do the front end of a form, because server technology (ie a lot of coding) is required for the backend.

One solution to getting around the coding issue is to use the mailto function to send the information directly via email. This is used by setting up your form to look like this:

<form name="myform" action="mailto:someaddress@host.com">

This is not the best solution as you have no control over the content being submitted. The format of the text in the email will be scrunched together and is very difficult to read. You can use javascript to format the text, again a little out of the scope of this course, but there's nothing stopping the user from disabling javascript and then you still have the problem. In addition to this, the mailto method can be unreliable. This is because it required the user to have a mail client installed on their computer, ie. an email program like outlook express that has been set up with a e-mail account. If the user doesn't have this, the form will not get submitted.

For this class, we will be submitting the form to an echo page on my own server:


This code is only used to display the information submitted by the form, it does nothing with the information. This is just an easy way for you to view what information has been set immediately, once you leave this page the information will be gone.

So at this point I'm sure you're thinking, "what do I do after this class?". If you're feeling adventurous, you can take the web server technology course which will teach you how to write your own scripts for submitting forms, but remember that this will be a code intensive course. There are also sites on the internet that will write scripts for you. One example is Response-o-Matic which writes a CGI script for free. Note: I have not used this service before, they may even be better ones out there.

Form Validation

Another important aspect of a form is to validate the content the user is sending. There are two levels of validation. This first is javascript, the second is the server side code that you submit the form to. With Javascript you can make certain or all fields require, meaning that the form cannot be sent when certain fields are empty. You can also do validation to make sure the user entered a valid e-mail address or phone number. This type of validation which yes it's good for you, it's more for the user, to catch simple little mistakes. Validating for your own use should be done server side, where the user can't disable the validation. Again you do the same validations as the javscript, but here you also check to make sure that the user isn't trying to submit code that can execute and cause you a problem (an example would be submitting javascript code that makes an infinite loop). This is really important if the information is going live to a website or into a database.

We won't get into any server side code with this course, but later on we'll be looking at some of the pre-written javascript code tthat you can add to your page to validate your forms.

For more information on making the form in Dreamweaver, look at chapter 15 in the textbook (pg. 539 with the Dreamweaver MX 2004 text).