HTML Form Elements

Web forms are a tool that allow users to interact with a webpage by entering in information that is sent to the server for processing. If you spend any time at all on the internet you will have run into forms used in many different ways, such as signing up for or logging into an email service, sending emails, placing orders, answering questions on a poll, and many others.

HTML forms, after they are filled out and submitted by the user, will be sent to a page on the server that is specified in the opening form tag. That page should contain a script (PHP, etc.) that gathers the information submitted and handles it by printing it on the page, adding it to a database, emailing it to someone, etc.

The basic form element looks like this:

<form action="what-to-do-next.php" method="post"> </form>
or
<form action="what-to-do-next.php" method="get"> </form>

In the opening form tag, the "action" specifies the page that the user's data is sent to for processing when the form is submitted. The "method" determines how that the data is sent to that page. "Post" sends the data behind the scenes, so the user does not see the information that they sent. "Get" sends the data as a string at the end of the url, which the user can see in their address bar.

These basic form elements are pretty much useless on their own, so let's explore some of the more useful form elements these tags will enclose.