|
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: 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.
Here is the actual HTML that displays the above form in a new window.
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
|
|||||||||||