Forms are one of the most important parts of any website or web application. They are used to gather information from users and submit it to the server for processing. The HTML form tag is used to create a form on a web page.
In this HTML form tag tutorial in Hindi / Urdu, we will learn about the various attributes of the form tag and how to use them to create a simple web form. We will also learn how to process the data submitted by the user using PHP.
The action attribute of the form tag is used to specify the URL of the page where the form data will be submitted. The method attribute is used to specify the HTTP method (GET or POST) that will be used to submit the form data. The GET method appends the Form Data as a query string to the URL, while the POST method sends the Form Data as a separate HTTP request body.
The enctype attribute is used to specify how the form data should be encoded when it is submitted to the server. The default value is application/x-www-form-urlencoded, which encodes the Form Data as a query string. If you are using file uploads, then you should set this attribute to multipart/form-data.
The target attribute is used to specify where the response from the server should be displayed. The default value is _self, which displays the response in the same window as where the form was submitted. You can also set this attribute to _blank, which will open a new window for displaying the response.
The name attribute is used to give a name to the form so that it can be identified on the server side when processing the data submitted by the user. This is an optional attribute but it is generally a good idea to give your forms a name so that they can be easily identified in your code.
The accept-charset attribute is used to specify which character sets are allowed for submitting data in this form. The default value is ISO-8859-1, which allows only characters in that character set to be submitted. You can change this value to allow other character sets such as UTF-8 or Unicode.
The autocomplete attribute specifies whether or not autocomplete should be enabled for this form element. The default value is “on” but you can set it to “off” if you don’t want autocomplete enabled for this element. Autocomplete simply means that browsers remember what values were entered into input fields so that they can be easily populated again if someone visits your site again at a later time. This can be useful for things like login forms where you want browsers to fill in your username and password for you so that you don’t have to retype them every time you visit your site. However, it can also be a security risk because if someone gets access to your computer, they may also be able to see what values were entered into these fields previously. For this reason, it’s generally best practice to disable autocomplete unless you have a good reason for enabling it.
The novalidate attribute specifies whether or not browser validation should be disabled for this form element. The default value is “off” but you can set it to “on” if you don’t want browser validation performed on this element’s data before it’s submitted (for example, if you’re using your own custom JavaScript validation). Disabling browser validation can be useful in some situations but it’s generally best practice to leave it enabled unless you have a good reason for disabling it. Browser validation simply means that browsers check certain things like whether required fields have been filled out before allowing users to submit forms. This helps prevent problems like users forgetting required information or accidentally entering invalid data into fields