MyWebServer
Home Free Downloads Docs FAQ's The Collective Community Tools Help About MyWebServer

MyWebServer |   Technical Info
 
  Creating And Handling Forms

Forms are a great way of getting input from your users. If you want to take a survey, want to know how your viewers found your web site or just about anything else, forms are the way to do it. Web forms are sections of web pages that usually contains some type of data entry or display widgets like text entry fields, lists or check boxes. There is usually a button that is associated with the form which takes some action like submitting the information on the form or starting a search etc. The action is usually handled by a CGI (Common Gateway Interface) program or script which runs on the web server and is written to extract the data from the form and do something with it like store it in a database or do a search etc. Another thing that CGI programs usually do is display something in the users web browser like a message saying the information has been submitted or listing the results of a search etc. There are some great generic CGI scripts and programs available like FormMail by Matt Wright that E-Mail all the data items on a form to a particular web address and inform the user that the data was submitted.

MyWebServer has a built in form handler that downloads all the data that was entered on a form to a file in a directory you specify. Every time somebody clicks on the submit button on a web form using this handler a new file is created. More about this later.

All Forms begin with an opening tag looks something like the following:

<FORM METHOD="POST" ACTION="the url of your CGI program">

You almost always want to use POST as the METHOD, especially if you are asking for a password or other private information.

The ACTION attribute should be set to the URL of the program that takes care of your results. MyWebServers Generic Post Handlers are always available and ready to receive the data from any form when a user clicks on the submit button. Use the Virtual Files MWS/HandlePost.html,  MWS/HandlePostRaw.html or MWS/HandlePosPlusHeaders.html as the "action" of your forms and POST as the "method". These Generic Form handlers gather the data from the form and stores it in a text file in the directory specified in the Server Properties Page.

MWS/HandlePost.html                Saves HEADERS and CONTENT (standard).
MWS/HandlePostRaw.html          Saves HEADERS, ENVIRONMENT and CONTENT.
MWS/HandlePosPlusHeaders.html   Saves CONTENT and HEADERS separately.

The form opening tags for these handlers might look something like this.

<FORM METHOD="POST" ACTION="../../../MWS/HandlePost.html">

<FORM METHOD="POST" ACTION="../../MWS/HandlePostRaw.html">

<FORM METHOD="POST" ACTION="../MWS/HandlePostPlusHeaders.html">

The trickiest part about using MyWSebServer's built in form handlers is that you need to refer to the handler by relative addressing. That is you need to include the path to the handlers relative to the location of the page that is referring to it. In the above examples each of the ../ in the paths indicate how many directories up the hierarchy the MWS directory may be found. See the article on Using The MyWebServer Virtual Toolbar for a more in depth explanation of relative addressing.

The closing tag for a form looks something like this </FORM>.

In between the beginning form tag and the closing form tag are HTML descriptions of the widgets and data displayed in the form.

You now have enough information to start implementing your own forms in HTML. The following is an example of a simple registration form one might use to collect the names and addresses of people that want register for a free newsletter or catalog.

 Catalog Order Form
Click Here to view the form in a new window.

Here is the actual HTML that displays the above form in a new window.

 Catalog Order Form 
<HTML>
<HEAD>
<TITLE>Catalog Order Form</TITLE>
</HEAD>

<BODY>

   <form method="POST" action="
../MWS/HandlePost.html">
      <p align="right">
      Name:<input type="text" name="Name" size="60"><br>
      Address:<input type="text" name="Address" size="60"><br>
      City:<input type="text" name="City" size="60"><br>
      State:<input type="text" name="State" size="60"><br>
      Zip:<input type="text" name="Zip" size="60"><br>
      Phone:<input type="text" name="Phone" size="60"><br>
      E-Mail:<input type="text" name="EMailAddress" size="60"><br>
      <input type="submit" value="Submit" name="B1">
      <input type="reset" value="Reset" name="B2">
   </form>


</BODY>

</HTML

Click Here to download this file.

If you place this file in your MyWebServer root directory and name it catalogOrderForm.html you will be able to use the form on your computer with the following URL. http://localhost/catalogOrderForm.html

 

 


 
 

[ Home ] [ Downloads ] [ Docs ] [ FAQs ] [ The Collective ] [ Community ] [ Tools ] [ Help ] [ About ]