{"id":6763,"date":"2018-10-25T07:00:17","date_gmt":"2018-10-25T11:00:17","guid":{"rendered":"http:\/\/local.brightwhiz\/?p=6763"},"modified":"2021-12-08T11:29:50","modified_gmt":"2021-12-08T16:29:50","slug":"how-to-use-both-get-and-post-methods","status":"publish","type":"post","link":"http:\/\/local.brightwhiz\/how-to-use-both-get-and-post-methods\/","title":{"rendered":"How to use Both GET and POST Methods in one Request"},"content":{"rendered":"\n

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.<\/p>\n\n\n\n

This is not typically taught in your run-off-the-mill web design<\/a> course and that could play out as to why this could be a question in your mind whether or not you are new to the web development<\/a> game.<\/p>\n\n\n\n

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.<\/p>\n\n\n\n

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.<\/p>\n\n\n\n

As the web developer, you have complete control as to how you handle these variables and create an experience for your users.<\/p>\n\n\n\n

When Should you use GET and POST Methods?<\/h2>\n\n\n\n

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.<\/p>\n\n\n\n

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.<\/p>\n\n\n\n

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
eyes.<\/p>\n\n\n\n

This data includes multi-part data collected through HTML<\/a> forms such as emails and their attachments, login and registration forms, etc.<\/p>\n\n\n\n

How About if you Want to use Both in one Action?<\/h2>\n\n\n\n

There are no restrictions on combining the methods, this is more of a design issue than a technical one. Here we will show you the solution using a simple HTML form and using JavaScript to process the form.<\/p>\n\n\n\n

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.<\/p>\n\n\n\n

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.<\/p>\n\n\n\n

<form action="example.php?var1=get1&var2=get2&var3=get3" method="post">\n\n    <input type="hidden" name="var4" value="post1" \/>\n    <input type="hidden" name="var5" value="post2" \/>\n\n    <input type="submit" value="Submit" \/>\n<\/form><\/code><\/pre>\n\n\n\n

The above is an example of a form that submits data using both the GET and POST methods.<\/p>\n","protected":false},"excerpt":{"rendered":"

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…<\/p>\n","protected":false},"author":1,"featured_media":6765,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,27,16],"tags":[170,303,328,471,635,637,638],"yoast_head":"\nYes you can use Both GET and POST Methods in one Request<\/title>\n<meta name=\"description\" content=\"You can use both GET and POST methods in your HTML form requests by simply using a query string in the action and POST as the method\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/local.brightwhiz\/how-to-use-both-get-and-post-methods\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Yes you can use Both GET and POST Methods in one Request\" \/>\n<meta property=\"og:description\" content=\"You can use both GET and POST methods in your HTML form requests by simply using a query string in the action and POST as the method\" \/>\n<meta property=\"og:url\" content=\"http:\/\/local.brightwhiz\/how-to-use-both-get-and-post-methods\/\" \/>\n<meta property=\"og:site_name\" content=\"Brightwhiz.com\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/brightwhiz\/\" \/>\n<meta property=\"article:published_time\" content=\"2018-10-25T11:00:17+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-12-08T16:29:50+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/local.brightwhiz\/wp-content\/uploads\/2018\/10\/html-form.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Michael Bright\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@brightwhizmag\" \/>\n<meta name=\"twitter:site\" content=\"@brightwhizmag\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Michael Bright\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"http:\/\/local.brightwhiz\/how-to-use-both-get-and-post-methods\/#article\",\"isPartOf\":{\"@id\":\"http:\/\/local.brightwhiz\/how-to-use-both-get-and-post-methods\/\"},\"author\":{\"name\":\"Michael Bright\",\"@id\":\"http:\/\/local.brightwhiz\/#\/schema\/person\/81f0f3126f13834ae2e7f381b3028e32\"},\"headline\":\"How to use Both GET and POST Methods in one Request\",\"datePublished\":\"2018-10-25T11:00:17+00:00\",\"dateModified\":\"2021-12-08T16:29:50+00:00\",\"mainEntityOfPage\":{\"@id\":\"http:\/\/local.brightwhiz\/how-to-use-both-get-and-post-methods\/\"},\"wordCount\":444,\"publisher\":{\"@id\":\"http:\/\/local.brightwhiz\/#organization\"},\"image\":{\"@id\":\"http:\/\/local.brightwhiz\/how-to-use-both-get-and-post-methods\/#primaryimage\"},\"thumbnailUrl\":\"http:\/\/local.brightwhiz\/wp-content\/uploads\/2018\/10\/html-form.jpg\",\"keywords\":[\"CSS\",\"HTML\",\"JavaScript\",\"Programming\",\"Web\",\"Web Design\",\"Web Development\"],\"articleSection\":[\"Articles\",\"Programming\",\"Technology\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"http:\/\/local.brightwhiz\/how-to-use-both-get-and-post-methods\/\",\"url\":\"http:\/\/local.brightwhiz\/how-to-use-both-get-and-post-methods\/\",\"name\":\"Yes you can use Both GET and POST Methods in one Request\",\"isPartOf\":{\"@id\":\"http:\/\/local.brightwhiz\/#website\"},\"primaryImageOfPage\":{\"@id\":\"http:\/\/local.brightwhiz\/how-to-use-both-get-and-post-methods\/#primaryimage\"},\"image\":{\"@id\":\"http:\/\/local.brightwhiz\/how-to-use-both-get-and-post-methods\/#primaryimage\"},\"thumbnailUrl\":\"http:\/\/local.brightwhiz\/wp-content\/uploads\/2018\/10\/html-form.jpg\",\"datePublished\":\"2018-10-25T11:00:17+00:00\",\"dateModified\":\"2021-12-08T16:29:50+00:00\",\"description\":\"You can use both GET and POST methods in your HTML form requests by simply using a query string in the action and POST as the method\",\"breadcrumb\":{\"@id\":\"http:\/\/local.brightwhiz\/how-to-use-both-get-and-post-methods\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/local.brightwhiz\/how-to-use-both-get-and-post-methods\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/local.brightwhiz\/how-to-use-both-get-and-post-methods\/#primaryimage\",\"url\":\"http:\/\/local.brightwhiz\/wp-content\/uploads\/2018\/10\/html-form.jpg\",\"contentUrl\":\"http:\/\/local.brightwhiz\/wp-content\/uploads\/2018\/10\/html-form.jpg\",\"width\":1200,\"height\":630,\"caption\":\"Get and Post Methods\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/local.brightwhiz\/how-to-use-both-get-and-post-methods\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/local.brightwhiz\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to use Both GET and POST Methods in one Request\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/local.brightwhiz\/#website\",\"url\":\"http:\/\/local.brightwhiz\/\",\"name\":\"Brightwhiz.com\",\"description\":\"Best Tech guides, Tutorials, and News\",\"publisher\":{\"@id\":\"http:\/\/local.brightwhiz\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/local.brightwhiz\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"http:\/\/local.brightwhiz\/#organization\",\"name\":\"Brightwhiz\",\"url\":\"http:\/\/local.brightwhiz\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/local.brightwhiz\/#\/schema\/logo\/image\/\",\"url\":\"http:\/\/local.brightwhiz\/wp-content\/uploads\/2021\/11\/brightwhiz-com-logo-orange.png\",\"contentUrl\":\"http:\/\/local.brightwhiz\/wp-content\/uploads\/2021\/11\/brightwhiz-com-logo-orange.png\",\"width\":706,\"height\":135,\"caption\":\"Brightwhiz\"},\"image\":{\"@id\":\"http:\/\/local.brightwhiz\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/brightwhiz\/\",\"https:\/\/x.com\/brightwhizmag\",\"https:\/\/instagram.com\/bright_whiz\/\",\"https:\/\/www.pinterest.com\/sobbayi\/\",\"https:\/\/www.youtube.com\/channel\/UC6sCdP_d_RiTIM7ErFT-PSQ\"]},{\"@type\":\"Person\",\"@id\":\"http:\/\/local.brightwhiz\/#\/schema\/person\/81f0f3126f13834ae2e7f381b3028e32\",\"name\":\"Michael Bright\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/local.brightwhiz\/#\/schema\/person\/image\/\",\"url\":\"http:\/\/1.gravatar.com\/avatar\/da90485875ff0aafa38fdd494abe87d1?s=96&d=mm&r=g\",\"contentUrl\":\"http:\/\/1.gravatar.com\/avatar\/da90485875ff0aafa38fdd494abe87d1?s=96&d=mm&r=g\",\"caption\":\"Michael Bright\"},\"sameAs\":[\"https:\/\/sobbayi.com\"],\"url\":\"http:\/\/local.brightwhiz\/author\/sobbayiadmin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Yes you can use Both GET and POST Methods in one Request","description":"You can use both GET and POST methods in your HTML form requests by simply using a query string in the action and POST as the method","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/local.brightwhiz\/how-to-use-both-get-and-post-methods\/","og_locale":"en_US","og_type":"article","og_title":"Yes you can use Both GET and POST Methods in one Request","og_description":"You can use both GET and POST methods in your HTML form requests by simply using a query string in the action and POST as the method","og_url":"http:\/\/local.brightwhiz\/how-to-use-both-get-and-post-methods\/","og_site_name":"Brightwhiz.com","article_publisher":"https:\/\/www.facebook.com\/brightwhiz\/","article_published_time":"2018-10-25T11:00:17+00:00","article_modified_time":"2021-12-08T16:29:50+00:00","og_image":[{"width":1200,"height":630,"url":"http:\/\/local.brightwhiz\/wp-content\/uploads\/2018\/10\/html-form.jpg","type":"image\/jpeg"}],"author":"Michael Bright","twitter_card":"summary_large_image","twitter_creator":"@brightwhizmag","twitter_site":"@brightwhizmag","twitter_misc":{"Written by":"Michael Bright","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"http:\/\/local.brightwhiz\/how-to-use-both-get-and-post-methods\/#article","isPartOf":{"@id":"http:\/\/local.brightwhiz\/how-to-use-both-get-and-post-methods\/"},"author":{"name":"Michael Bright","@id":"http:\/\/local.brightwhiz\/#\/schema\/person\/81f0f3126f13834ae2e7f381b3028e32"},"headline":"How to use Both GET and POST Methods in one Request","datePublished":"2018-10-25T11:00:17+00:00","dateModified":"2021-12-08T16:29:50+00:00","mainEntityOfPage":{"@id":"http:\/\/local.brightwhiz\/how-to-use-both-get-and-post-methods\/"},"wordCount":444,"publisher":{"@id":"http:\/\/local.brightwhiz\/#organization"},"image":{"@id":"http:\/\/local.brightwhiz\/how-to-use-both-get-and-post-methods\/#primaryimage"},"thumbnailUrl":"http:\/\/local.brightwhiz\/wp-content\/uploads\/2018\/10\/html-form.jpg","keywords":["CSS","HTML","JavaScript","Programming","Web","Web Design","Web Development"],"articleSection":["Articles","Programming","Technology"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"http:\/\/local.brightwhiz\/how-to-use-both-get-and-post-methods\/","url":"http:\/\/local.brightwhiz\/how-to-use-both-get-and-post-methods\/","name":"Yes you can use Both GET and POST Methods in one Request","isPartOf":{"@id":"http:\/\/local.brightwhiz\/#website"},"primaryImageOfPage":{"@id":"http:\/\/local.brightwhiz\/how-to-use-both-get-and-post-methods\/#primaryimage"},"image":{"@id":"http:\/\/local.brightwhiz\/how-to-use-both-get-and-post-methods\/#primaryimage"},"thumbnailUrl":"http:\/\/local.brightwhiz\/wp-content\/uploads\/2018\/10\/html-form.jpg","datePublished":"2018-10-25T11:00:17+00:00","dateModified":"2021-12-08T16:29:50+00:00","description":"You can use both GET and POST methods in your HTML form requests by simply using a query string in the action and POST as the method","breadcrumb":{"@id":"http:\/\/local.brightwhiz\/how-to-use-both-get-and-post-methods\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/local.brightwhiz\/how-to-use-both-get-and-post-methods\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/local.brightwhiz\/how-to-use-both-get-and-post-methods\/#primaryimage","url":"http:\/\/local.brightwhiz\/wp-content\/uploads\/2018\/10\/html-form.jpg","contentUrl":"http:\/\/local.brightwhiz\/wp-content\/uploads\/2018\/10\/html-form.jpg","width":1200,"height":630,"caption":"Get and Post Methods"},{"@type":"BreadcrumbList","@id":"http:\/\/local.brightwhiz\/how-to-use-both-get-and-post-methods\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/local.brightwhiz\/"},{"@type":"ListItem","position":2,"name":"How to use Both GET and POST Methods in one Request"}]},{"@type":"WebSite","@id":"http:\/\/local.brightwhiz\/#website","url":"http:\/\/local.brightwhiz\/","name":"Brightwhiz.com","description":"Best Tech guides, Tutorials, and News","publisher":{"@id":"http:\/\/local.brightwhiz\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/local.brightwhiz\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"http:\/\/local.brightwhiz\/#organization","name":"Brightwhiz","url":"http:\/\/local.brightwhiz\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/local.brightwhiz\/#\/schema\/logo\/image\/","url":"http:\/\/local.brightwhiz\/wp-content\/uploads\/2021\/11\/brightwhiz-com-logo-orange.png","contentUrl":"http:\/\/local.brightwhiz\/wp-content\/uploads\/2021\/11\/brightwhiz-com-logo-orange.png","width":706,"height":135,"caption":"Brightwhiz"},"image":{"@id":"http:\/\/local.brightwhiz\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/brightwhiz\/","https:\/\/x.com\/brightwhizmag","https:\/\/instagram.com\/bright_whiz\/","https:\/\/www.pinterest.com\/sobbayi\/","https:\/\/www.youtube.com\/channel\/UC6sCdP_d_RiTIM7ErFT-PSQ"]},{"@type":"Person","@id":"http:\/\/local.brightwhiz\/#\/schema\/person\/81f0f3126f13834ae2e7f381b3028e32","name":"Michael Bright","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/local.brightwhiz\/#\/schema\/person\/image\/","url":"http:\/\/1.gravatar.com\/avatar\/da90485875ff0aafa38fdd494abe87d1?s=96&d=mm&r=g","contentUrl":"http:\/\/1.gravatar.com\/avatar\/da90485875ff0aafa38fdd494abe87d1?s=96&d=mm&r=g","caption":"Michael Bright"},"sameAs":["https:\/\/sobbayi.com"],"url":"http:\/\/local.brightwhiz\/author\/sobbayiadmin\/"}]}},"_links":{"self":[{"href":"http:\/\/local.brightwhiz\/wp-json\/wp\/v2\/posts\/6763"}],"collection":[{"href":"http:\/\/local.brightwhiz\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/local.brightwhiz\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/local.brightwhiz\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/local.brightwhiz\/wp-json\/wp\/v2\/comments?post=6763"}],"version-history":[{"count":0,"href":"http:\/\/local.brightwhiz\/wp-json\/wp\/v2\/posts\/6763\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/local.brightwhiz\/wp-json\/wp\/v2\/media\/6765"}],"wp:attachment":[{"href":"http:\/\/local.brightwhiz\/wp-json\/wp\/v2\/media?parent=6763"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/local.brightwhiz\/wp-json\/wp\/v2\/categories?post=6763"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/local.brightwhiz\/wp-json\/wp\/v2\/tags?post=6763"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}