+ 3

Method attribute

When using, radio buttons, check boxes or drop down lists, why isn't the method (post) attribute used? Method attributes are used to add info to a database, so why don't we use the method attribute in all form controls mentioned above?

1st Jul 2018, 11:35 PM
arbaaz
8 Respostas
+ 1
Mohammad Yahya yeah, but post/get isn't used for buttons or drop downs. because for such tasks no server requests are needed, second because it's not possible using those methods outside of the xhttp object.
2nd Jul 2018, 4:08 AM
wenz
wenz - avatar
+ 1
wenz ,Yes, that is true, but I explained the general state of form method so that the programmer can make the right choice and understand the principles of the work. Your comment is completely correct. Thanks again👌😉
2nd Jul 2018, 4:13 AM
Root
Root - avatar
+ 1
Little unsure exactly what you are asking. If the "method" attribute is not included in the <form> tag, it defaults to GET when the form is submitted. The type of form inputs (radio buttons, check boxes, etc) has no direct meaning on which form method to use. While GET is intended for retrieving data and POST is intended for adding/updating data, in actual usage both methods can be used for either purpose. The key difference to actually remember is HOW they submit the form data. GET method includes all form data in the URL of the HTTP(S) request. The URL has a fixed max length so there is a limit on how much form data it can include. Since the URL includes the form data, the completed form can be bookmarked by the browser. POST method includes all form data in the body of the HTTP(S) request. The total request can be as long as needed so there is no limit on how much form data can be submitted. Since the form data is completely separate from the URL, the completed form can not be bookmarked by the browser. If the request uses HTTPS, all of the request will be encrypted including the URL so form data in both GET and POST requests is safe from Man-in-the-Middle snooping. However due to browser caching and bookmarking, you should not use GET for any sensitive form data. Both GET and POST are equally insecure when used in an HTTP request. Whether to use GET or POST for your form will primarily depend on 3 factors: * form data size * how sensitive is the form data * whether you want to bookmark the completed form
3rd Jul 2018, 5:57 AM
Shardis Wolfe
0
post and get is used in xhttp.open() or .send(). for buttons and stuff event listeners are used. I don't know why, but my best guess is because of security concerns
2nd Jul 2018, 3:38 AM
wenz
wenz - avatar
0
Hi arbaaz & wenz , According to sololearn HTML course, "When you use GET, the form data will be visible in the page address. (people can see datas). Use POST if the form is updating data, or includes 🔮sensitive information🔮 (passwords). POST offers better security because the submitted data is not visible in the page address." So, if your data is sensitive you must use POST method, otherwise GET is better. POST method, encrypt your data. Also: GET is used to request data from a specified resource. But, POST is used to send data to a server to create/update a resource. The data sent to the server with POST is stored in the request body of the HTTP request: 🔮🔮For more information about form methods and differences of GET & POST method, see "Compare GET vs. POST" section in below link: https://www.w3schools.com/tags/ref_httpmethods.asp Goodluck 😉 🙋
2nd Jul 2018, 3:56 AM
Root
Root - avatar
0
Can I use the align attribute for the head tag???
2nd Jul 2018, 12:44 PM
Sreenath Reddy
Sreenath Reddy - avatar
0
Hi Sreenath Reddy ,no you can not. Align attribute used in body and its children. [UPDATE] See below link for more information : https://www.w3schools.com/html/html_head.asp
2nd Jul 2018, 2:02 PM
Root
Root - avatar
0
Thank you all for your answers.
4th Jul 2018, 7:32 PM
arbaaz