Forms are ways of providing information, and so is an HTML form, but rather on a web page, using a browser. As much as a normal paper form contains fields to fill in your details, and after that, you can submit to someone in charge, so HTML forms also provide inputs fields, which serve as fields that allow you to fill in your data and submit to the server for some processing and back to the person-in-charge (the developer).

The above things are however not new to a web developer, as millions of forms are being filled on websites daily. But whether you are new to the game or a professional. This tutorial tells all that you need to know about HTML Forms, including HTML form action, form methods, HTML form encoding types, and form processing.

Let’s dive into the details!

HTML Form Action

HTML Form actions point to where the form should be submitted. This is done with the action attribute. The value of the action attribute is typically a URL to an external or internal page.

Example

<form action="https://example.com" method="GET"> ... </form>

HTML Form Methods

Form methods tell the browser to send the users’ data, and in other ways tells the server how to process the provided information by your user. This is possible in HTML form by using the method attribute. This attribute can either be "GET" or "POST" depending on the purpose of the form.

The GET Method

The GET method tells the browser to include all the form data in the URL after submitting. Each piece of data appears by sending the URL in the action attribute, followed by ? followed by key=value. This method should be used for processing less-sensitive data, such as name search or getting content per user (/?username=Bob), and should not be used for processing sensitive information such as passwords. We will discuss a method suitable for processing sensitive data in the next section. Let’s use a live example.

Example: GET Method

<form method="GET" action="search.php">  
<input type="search" name="key" /> <input type="submit" value="Search" name="submit" /> </form>   

When this form is submitted, the processed URL will result in something like /search.php?key=hello&submit=Search. You can see that all users’ information is displayed on the URL in the format of key=value. The example stands as a good reason for you to know why it is bad and not advisable to include sensitive information on a GET form. Let’s look into a bad way of using GET method.

Note

The key is the value provided in the attribute of each form field, therefore the name attribute is important in HTML form processing.

Wrong Example: POST Method

Take a look at the example above, so for example, assuming user enters the username ola and password and clicks on login, this will result to a URL: /login.php?username=ola&password=password&submit=Login, revealing sensitive information on the browser’s URL, this can be used by hackers to get vital information, and get access to personal accounts.

#html-fundamentals #html #html5 #tutorial #html-forms #guide-to-html-forms #latest-tech-stories #php

All You Need To Know About HTML Forms
2.30 GEEK