POST / GET ??? what's the difference

Could someone tell me what's the difference between POST and GET with an example for each please?
flealAsked:
Who is Participating?
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.