HTML web forms are a composition of buttons, checkboxes, and text input fields embedded inside of HTML documents with one goal in mind: to capture user input. By doing things such as providing fields for user data such as names, phone number, and email addresses, web forms give users the opportunity to interact directly with a webpage.
HTML forms are placed on a web page using the <form> tag. This tag should encapsulate a series of other form elements, identifying them as a single cohesive web form.
HTML Form Element: <form name="myWebForm" action="myServerSideScript.php" method="post"> <input type="checkbox" /> Checkbox 1<br /> <input type="text" /> Text Field 1<br /> <input type="submit" value="SUBMIT" /> </form>
HTML Web Form:
-------------------------------------------------
Top of Form
Checkbox 1
Text Field 1
Bottom of Form
HTML form elements rely on action and method attributes to identify where to send the form data for processing (action) and how to process the data (method). In the code above, we've inserted some make-believe values to represent what a typical HTML form might look like behind the scenes.
Unfortunately, HTML alone is unable to process form data. A scripting language such as PHP, PERL, and/or JavaScript must be used with HTML forms to process data captured by HTML form elements. A complete form-processing example using PHP can be found here: PHP Form Processing Example.
For the purpose of following along, we can also adjust the action property slightly to have the form launch an email client instead of processing a make-believe server-side script. This will provide us with some form interactivity for us as we learn more about HTML forms.
HTML Email Form Element: <form name="myWebForm" action="mailto:youremail@email.com" method="post">