Include a web form

Those who have a web page like to get feedback from their readers. Not just that, web pages are also effective ways to sell products, enhance campaigns and a number of other things like search within the contents of your site! To give your visitors a space to communicate with you, you need to offer them a web form. The code for the web page is easy, the instructions on how to process the information go in a separate file.

Start by telling the computer you are publishing a web form. To do this, use the <form></form> tag, but this time include both the method and the action this form will process.

When you get information from your site to the visitor, you use the 'get' method; to have your visitor provide you with information, you use the 'post' method:

<form method="post"></form>

Next, include the name of the file where the processing instructions are written. Use the 'action' attribute to do this:

<form method="post" action="instructions.php"></form>

Ready. Now provide the spaces in which the visitor is going to request or send you information. You need to specify a name for each of these parts:

For short things, use the <input /> tag. Include the name and the type of field, like this:

<input name="your-name" type="text" />
For small lines of text.

<input name="your-password" type="password" />
For small lines of hidden text (passwords).

<input name="your-file" type="file" />
To select and upload a file.

<input name="your-selection" type="radio" />
To choose options with a radio button.

<input name="yes-or-no" type="checkbox" />
To have your visitor mark an option if he wants.

<input name="submit" type="submit" />
To have the visitor send your form to you.

For long things, use the <textarea></textarea> field, specifying its name and the number of rows and columns your text area will have:

<textarea name="message" rows="3" cols="45"></textarea>

Include all the fields you need within your <form></form> tag, and save your file. That's it.

Knowledge + Computers