Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win



Posted on 2000-04-18
Medium Priority
Last Modified: 2013-12-25
What is the difference between Post and Get?
Question by:bea_pr
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2

Expert Comment

ID: 2729282
Hi there,

The POST method is used whenever the name and values of form elements submitted are not to be shown in the URL but the information goes in the header whereas in the GET method u can clearly see the entire list of form elements(name-value pairs) appearing along with the URL.

Hope this clarifies ur doubt.

LVL 16

Accepted Solution

maneshr earned 40 total points
ID: 2731450
Here is some info on your Question.

CGI scripts are called in two main ways, referred to as methods .
The HTTP GET method is used in document retrievals where an identical request will produce an identical result, such as a
dictionary lookup. A GET stores form data in the URL. This means it can be conveniently bookmarked for canned requests,
but has limitations on the total size of the data requested. The HTTP POST method sends form data separate from the request.
It has no such size limitations, but cannot be bookmarked. Forms that update information on the server, like mailing in feedback
or modifying a database entry, should use POST. Client browsers and intervening proxies are free to cache and refresh the
results of GET requests behind your back, but they may not cache POST requests. GET is only safe for short read-only
requests, whereas POST is safe for forms of any size, as well as for updates and feedback responses. Therefore, by default,
the CGI module uses POST for all forms it generates.
CGI programs are called each time the web server needs a dynamic document generated. It is important to understand that
your CGI program doesn't run continuously, with the browser calling different parts of the program. Each request for a partial
URL corresponding to your program starts a new copy. Your program generates a page for that request, then quits.

A browser can request a document in a number of ways called methods. (Don't confuse HTTP methods with the methods of
object-orientation. They have nothing to do with each other). The GET method is the most common, indicating a simple request
for a document. The HEAD method is used when the browser wants to know about the document without actually fetching it.
The POST method is used to submit form values.

Form values can be encoded in both GET and POST methods. With the GET method, values are encoded in the URL, leading
to ugly URLs like this:


With the POST method, values are in a different part of the HTTP request that the browser sends the server. If the form values
in the example URL above were sent with a POST request, the user, server, and CGI script all see the URL:


The GET and POST methods differ in another respect: idempotency. This simply means that making a GET request for a
particular URL once or multiple times should be no different. This is because the HTTP protocol definition says that a GET
request may be cached by the browser, or server, or an intervening proxy. POST requests cannot be cached, because each
request is independent and matters. Typically, POST requests changes or depends on the state of the server (query or update a
database, send mail, or purchase a computer).

Transferring the Form Data

Parameters to a CGI program are transferred either in the URL or in the body text of the request. The method used to pass
parameters is determined by the method attribute to the <form> tag. The GET method says to transfer the data within the URL
itself; for example, under the GET method, the browser might initiate the HTTP transaction as follows:

     GET /cgi-bin/guestbook.pl?firstname=Joe&lastname=Schmoe HTTP/1.0

The POST method says to use the body portion of the HTTP request to pass parameters. The same transaction with the POST
method would read as follows:

     POST /cgi-bin/guestbook.pl HTTP/1.0
             ... [More headers here]


In both of these examples, you should recognize the firstname and lastname variable names that were defined in the HTML
form, coupled with the values entered by the user. An ampersand (&) is used to separate the variable=value pairs.

The server now passes the variable=value pairs to the CGI program. It does this either through Unix environment variables or
in standard input (STDIN). If the CGI program is called with the GET method, then parameters are expected to be embedded
into the URL of the request, and the server transfers them to the program by assigning them to the QUERY_STRING
environment variable. The CGI program can then retrieve the parameters from QUERY_STRING as it would read any
environment variable (for example, from the %ENV hash in Perl). If the CGI program is called with the POST method,
parameters are expected to be embedded into the body of the request, and the server passes the body text to the program as
standard input (STDIN).

Author Comment

ID: 2736981
What would be better for a form used for a search engine donde in C++?

Author Comment

ID: 2740132
LVL 16

Expert Comment

ID: 2740445
i would suggest you use POST due to the advantages i mentioned above.

Hope that helps.

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Making a simple AJAX shopping cart Couple years ago I made my first shopping cart, I used iframe and JavaScript, it was very good at that time, there were no sessions or AJAX, I used cookies on clients machine. Today we have more advanced techno…
It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question