Log in

View Full Version : forms



jr_yeo
07-19-2006, 05:36 PM
What's the difference between $_POST and $_GET? :D

can the two be use interchangeably? :p tnx :D

Twey
07-19-2006, 06:18 PM
Simply put, GET variables are those passed by a form with method="get" or no method, while POST variables are those passed by a form with method="post".

On a lower level, GET and POST are two different ways of sending data in HTTP. GET requests pass the data via the resource string. This can be seen in URLs such as
http://www.dynamicdrive.com/forums/showthread.php?p=44204and translates to the HTTP query (in HTTP 1.1):
GET /forums/showthread.php?p=44204 HTTP/1.1
Host: www.dynamicdrive.comThe same data sent by POST, however, would not be indicated in the URL. POST data is embedded in the request, and is therefore more flexible (GET can only send ASCII characters, and escaping all the non-ASCII characters could result in a 3x data size increase). Sending the same data by POST would translate into the following (skeleton) HTTP query:
POST /forums/showthread.php HTTP/1.1
Host: www.dynamicdrive.com
Content-Type: x-www-form-urlencoded
Content-Length: 7

p=44204