|How do I make a form?|
To make a form. (skip down to form configuration if you already know how to make a form with HTML)
First command you need is: <form method="post" action="/cgi-bin/formmail.pl">
And the last command you need is </form> (don't forget this one)
Now, there are different ways of people entering things. There is the Text Box, the Text Area Box, Radio Buttons, Check Boxes, and Drop Down Menu (there are others, but those are the ones I'm going to go over here)
Before we go into that, the different parts of an input tag that you use are: type, name, value, size, and maxlength. Not all are needed with all types. For instance, to have one of the configuration variables set, you use the type="hidden". Then you choose what is used, not your visitor.
To have the form mailed to you, you use this tag: <input type="hidden" name="recipient" value="email@example.com"> (putting your email address in there) so that your visitor won't see where it goes, but it will be mailed to you.
Now we go on to how to get input.
Simple, and to the point. <input type="text" name="your_choice_of_name" size="30" maxlength="50">
- Type="text" - this is the type of box it is - a text box
- Name= - this is what you want it called when it is emailed to you - totally your choice (don't make 2 the same)
- Size= - this is the length the box with be - how long it looks
- Maxlength= - this is how many characters this box will take
Radio buttons can only have one clicked at a time. <input type="radio" name="your_choice" value="choice">
- Type="radio" - the type it is - all radio buttons with the same name can only have one selected
- Name= - this groups the radio buttons - the name is emailed to you with the value that was selected
- Value= - the value is different for each button - it is what is chosen by the visitor
Check boxes are the same as radio buttons except the visitor can chose as many as they want.
<input type="checkbox" name="your choice" value="choice">
Each attribute means the same as with radio, except the type is checkbox.
Drop Down Menu
This type has a different set up.
<select name="your_choice" size="1">
Name is again your choice for the email. Size is how many lines you want shown. Selected is used to show which is the default. You can have as many or as few options as you want. Only one will be selected.
Text Area Box
<textarea name="your_choice" rows="3" cols="30"></textarea>
Again, very similar. Name is what it is emailed to you as. Rows are the number of rows in the box, cols is the number of columns in the box. Don't forget to close it.
Ending off the form<input type="submit" value="Submit the form"><input type="reset" value="Start Over">
This is your submit and reset buttons. The type is important. The value is what you want it to show on the button.
And then don't forget to close with the </form>
Necessary Form Fields
There is only one form field that you must have in your form, for our FormMail program to work correctly. This is the recipient field. You must also email us to let us know what it is. We have put a block in place that if you do not let us know what email you are using, it will not work.
Description: This form field allows you to specify to whom you wish for your form results to be mailed. Most likely you will want to configure this option as a hidden form field with a value equal to that of your e-mail address.
Syntax: <input type=hidden name="recipient" value="firstname.lastname@example.org">
Optional Form Fields
Description: The subject field will allow you to specify the subject that you wish to appear in the e-mail that is sent to you after this form has been filled out. If you do not have this option turned on, then the script will default to a message subject: WWW Form Submission
Syntax: If you wish to choose what the subject is: <input type=hidden name="subject" value="Your Subject">
To allow the user to choose a subject:
<input type="text" name="subject">
Description: This form field will allow the user to specify their return e-mail address. If you want to be able to return e-mail to your user, I strongly suggest that you include this form field and allow them to fill it in. This will be put into the From: field of the message you receive. If you want to require an email address with valid syntax, add this field name to the 'required' field.
Syntax: <input type=text name="email">
Description: The realname form field will allow the user to input their real name. This field is useful for identification purposes and will also be put into the From: line of your message header.
Syntax: <input type=text name="realname">
Description: If you wish to redirect the user to a different URL, rather than having them see the default response to the fill-out form, you can use this hidden variable to send them to a pre-made HTML page.
Syntax: To choose the URL they will end up at: <input type="hidden" name="redirect" value="http://your.host.com/to/file.html">
To allow them to specify a URL they wish to travel to once the form is filled out:
<input type=text name="redirect">
Description: You can require for certain fields in your form to be filled in before the user can successfully submit the form. Simply place all field names that you want to be mandatory into this field. If the required fields are not filled in, the user will be notified of what they need to fill in, and a link back to the form they just submitted will be provided.
To use a customized error page, see 'missing_fields_redirect'
Syntax: If you want to require that they fill in the email and phone fields in your form, so that you can reach them once you have received the mail, use a syntax like: <input type=hidden name="required" value="email,phone">
Description: This field allows you to choose the order in which you wish for your variables to appear in the e-mail that FormMail generates. You can choose to have the field sorted alphabetically or specify a set order in which you want the fields to appear in your mail message. By leaving this field out, the order will simply default to the order in which the browsers sends the information to the script (which is usually the exact same order as they appeared in the form.) When sorting by a set order of fields, you should include the phrase "order:" as the first part of your value for the sort field, and then follow that with the field names you want to be listed in the e-mail message, separated by commas. This version allows a little more flexibility in the listing of ordered fields, in that you can include spaces and line breaks in the field without it messing up the sort. This is helpful when you have many form fields and need to insert a line wrap.
To sort alphabetically: <input type=hidden name="sort" value="alphabetic">
To sort by a set field order: <input type=hidden name="sort" value="order:name1,name2,etc...">
Description: This form field allows you to specify a URL that users will be redirected to if there are fields listed in the required form field that are not filled in. This is so you can customize an error page instead of displaying the default.
Syntax: <input type=hidden name="missing_fields_redirect" value="http://your.host.com/error.html">
Any other form fields that appear in your script will be mailed back to you and displayed on the resulting page if you do not have the redirect field set. There is no limit as to how many other form fields you can use with this form, except the limits imposed by browsers.