• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 146
  • Last Modified:

POST / GET ??? what's the difference

Could someone tell me what's the difference between POST and GET with an example for each please?
0
fleal
Asked:
fleal
  • 4
1 Solution
 
jcondeCommented:
The difference between post and get is basically the way the parameters to the cgi are passed by.

while get reads the QUERY_STRING ambient variable, POST reads the standard input.

ej:

#include <stdio.h>

void main()
{
  char *cl;
  cl = getenv("QUERY_STRING");
  puts ("Content-Type:  text/html\n");
  printf ("%s",cl);
}

this example will print something like:
first=first+parameter&second=second+parameter.......
where first and second are the names of the controls you set in your form.

using post would be something like this:

#include <stdio.h>
void main()
{
char a[100];
printf ("Content-type: text/html\n\n");
fgets(a, 100, stdin);
printf ("%s",a);
}
this example will have the same output as the first.

with get, you can only send a few parameters to the cgi.  Thus makeing it unstable at some point.

with POST you override that problem.


--jconde
0
 
jcondeCommented:
Which one of those do you recommend for a simple search engine that will be using 6 parameters at the most?
0
 
jcondeCommented:
It doesnt matter! fleal, but try using post!
0
 
flealAuthor Commented:
Jconde,

I not be using 6 parameters.  I will be coding a shopping cart and there will be more than 6 parameters.

fleal.
0
 
jcondeCommented:
Ok, then you should consider using COOKIES instead!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now