Posted on 2000-04-18
Last Modified: 2013-12-25
What is the difference between Post and Get?
Question by:bea_pr
  • 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 10 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/ 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/ 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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Powershell  and PSExec = Password failure 5 25
BATCH to EXE Converter 2 71
Where to download python requests library 6 67
New-MoveRequest Exchange 2010 Powershell 1 42
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…
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

730 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