Learning HTML by yourself

B - Creating A Simple Form

11/11/2011 09:33

To create a form in a new language called XHTML you need to understand the parts of the forms.  So below is the parts.


This code is not that hard.  You need to have the work form, at the start and at the end.  This is where you will see the form elements.  Althought he form element istelf isn't usually a visible part of th epage (like the body tag), it could be with appropriated with CSS later on.

The word action indicates what should happen when the form is submitted.  This requires a programming language, but for now just understand that to have the " " after the equal sign makes it fso that there is no action.  If you want to see an action  you can change the action to the following:


The easiest way to write a form and send it to multiple people is to use a mailto form and use that to send it to multiple people. Put multiple email addresses in the action field by separating them with a comma:

<form action="mailto:email@address1.com,email@address2.com"> ... </form>



This example uses the "email-to" function of form-submit, which causes form results to be emailed to a specific email address, using a template file as a model for the message. Here, it's assumed that this form is being used by J. Random User, who has a Web page at https://www.mv.com/ipusers/jruser and an email user of jr@jruser.mv.com . J. Random has created a directory forms for various forms, including this one; and in this directory there are the following files that make this particular form work:

em.html - the HTML form itself

This is the form that the submitter fills in; submitting this form causes form-submit to email a message based on the information filled in here. This form asks for the submitter's name, email address, and some comments.




Your comments?


By filling out this small form you can send me some comments.


Your name:

Your email address:

Your comments?


The most important line is the reference to the form-submit utility: 


Here, the argument /ipusers/jrusers/forms gives the path from the top of the WWW tree to J. Random's forms directory, and the final element em identifies the form to be used. Given this, form-submit will take its directions from a file named em.submit in that forms directory.



The Form Submit file - the em.submit

The em.submit file tells form-submit how to proceed with processing the form submitted from em.html .


    # submit file for email form
    Tag-Required:	name
    Tag-Default	comments	""
    Email-file	em.template
    Email-to	jr@jruser.mv.com
    Return-document:	em-done.html

This file says that the submitter's name must be provided, and that the comments field, if omitted, will be set to blanks -- this will make sure that there is a translation for the comments field when it is included in the email message. The file also specifies that the results of the form should be emailed to jr@jruser.mv.com using the file em.template as a model. That file (the template file) contains form-submit style substitutions so that the actual submitted information can be sent in the desired format. Finally, the em.submit file says that when the form is successfully processed, a file em-done.html should be returned to the submitter as a confirmation page.


The Sumbit Control File -  


The em.template file is identified in the em.submit control file as the file that will be sent as email each time a submission is made. This template file has the appropriate forms-submit substitution strings so that the input data can be included in the email message.


    Subject: Comments from EM form
    Comments from:  ~name
    ~?~:email==yes ~{-
    Email:          ~email

Note that the first line of this template file can provide part of the email header; in this case the Subject: line is provided. A blank line should follow any header text provided. 
The sequence:


    ~?~:email==yes ~{-
    Email:          ~email

makes sure that the submitter's email address is included in the email message only if there was one provided. Note the use of the continuation characters to suppress extraneous blank lines.



This is simply a page that is returned to the submitter after the form has been processed.




Thank You


Your comments have been received. Please use your "back" function to return.