Because you are reading this, it tells me that you have somewhat wondered whether or what will happen should you want to use both GET and POST methods in your service requests.
Well, whenever a request is made from a web browser to a web server, there are a couple of unseen bits of data that are passed from the web browser to the server.
Depending on what you are doing this could be one or a combination of COOKIE, GET, and POST variables. Normally you do not control the passing of cookies as the casual website visitor but you may have more influence over the GET and POST methods based on your actions at the point in time.
As the web developer, you have complete control as to how you handle these variables and create an experience for your users.
When Should you use GET and POST Methods?
GET is usually ideal for passing non-sensitive information back to the server. These could be parameters that control which page or what parts of a page to load.
GET is also ideal for smaller amounts of data. A good cap would be about 1025 characters. It is also good to know that browsers have a limit as to how much data can be sent via GET and POST methods.
POST is usually good for handling lots of data that needs to be sent to the server as well as sensitive information that should not be visible to prying
This data includes multi-part data collected through HTML forms such as emails and their attachments, login and registration forms, etc.
How About if you Want to use Both in one Action?
When creating an HTML form you may set some attributes. These are the ACTION and the METHOD attributes. You must set the METHOD to “POST” to pass the form inputs as POST data.
To use the GET method, you then need to add the GET data directly as a query string in the ACTION parameter and it is as simple as that.
<form action="example.php?var1=get1&var2=get2&var3=get3" method="post"> <input type="hidden" name="var4" value="post1" /> <input type="hidden" name="var5" value="post2" /> <input type="submit" value="Submit" /> </form>
The above is an example of a form that submits data using both the GET and POST methods.