Html form is a web form present on webpage that allow user to enter data which is sent to the server for processing. Html forms are needed when you want to collect some information. Forms may be like paper or database forms because web users will be to fill forms by using checkboxes, radio buttons or text fields etc. For example, for registration you need some information like e-mail, first name, last name etc.
Http (hypertext transfer protocol) is designed for communication between server and client. Basically two methods are used for request response between server and client.
- Post method.
- Get method.
- It submits data that is to be processed to specified resource
- Requests can’t be cashed
- Requests never remain in browser history
- Requests can’t be able to bookmark
- Requests do not have restriction on data length, binary data also allowed
- It is secure
- Data is not visible in URL
- It requests data from specified resource
- Requests can be cashed
- Requests remain in browser history
- Requests have length restriction
- Requests should be used only for retrieve data
- Requests never used with sensitive data
- It is less secure
- Data is visible to everyone in URL
It defines action that is to be performed when your form is submitted. Basically form data is sent to server when user click submit button.
The method attributes
Method can be post or get when you are submitting data form.
<form action=”action_page.php” method=”get”>
<form action=”action_page.php” method=”post”>
When to use get method?
When we submit data then default method is get. When we use get method, then the submitted data is visible to everyone in the page address field. Get is not used when sending sensitive information, it is best for short and non-sensitive information only.
When to use post method?
Post method is used when form data contains sensitive information or personal information because it does not display submitted information in the page address .so it is secure method.
The Name attributes:
Every input field must have a name attribute that is to be submitted. If the name attribute is removing, the data of that input field will not be able to send.