Difference between $_GET & _POST with forms

Posted on 2005-03-30
Medium Priority
Last Modified: 2010-04-25

I would like to have a clear understanding of the difference between the two.  I seem to be able to use the $_GET method, accept with date, but have problems using the
$_POST.  I would be grateful for a clear description of the two methods and when it is best to use which.  What I do understand is the GET will send the info in the url, and that there is less characters, and it is less secure, however I would like to understand how values get from one page to the other with POST and what is needed to be done in a  Dreamweaver form.  Do I need to pass the values the same way I do wth the GET?  I do make sure my form action is GET or POST depending on which method I am using.

I have just made sure my registered_globals is disabled, as I did read a post here yesterday that may influence them and may have accounted for why they have not worked.  I am would be pleased for a clearer explanation if someone can help.
Question by:debbieau1
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
  • 3
  • 2
LVL 16

Accepted Solution

vickerleung earned 2000 total points
ID: 13667479

First of all, keep in mind that this involves two parties

The HTML form and the server side script
- HTML form is where the user fills in something
- Server side script is where the server process the form

Both side must agree / use the same method in order to achieve communications
That is the pairs below

<form action=xxxx method=GET></form> <----> $_GET
<form action=xxxx method=POST></form> <-----> $_POST

OK, explaining GET and POST method

- When data is passing from the form to the server side, the parameters / variables will be pass through the URL
- e.g. you will see something like this in the URL http://www.experts-exchange.com/login.php?account_id=12345&password=67890
- In here two parameters are passed, the first one is account_id and the second is password, I think is obvious :)
- The pros of this is it is easily to track what have passed to server side which is good when we are coding
- The cons of this is it is not secure, any one will see the parameters and they can try to crack through your code

- When data is passing from the form to the server side, the parameters / variables will be pass through the HTTP header
- That is, you won't be able to see it in URL or even source code. I will say nowhere.
- The pros of course is security issue
- The cons of course again is not convenient

My common practise is to use GET during development while POST during release

Hope it helps

Author Comment

ID: 13667504
Thanks Vicker for your thorough explanation.  Just two last questions if you don't mind  

 Do I pass the parameters with POST the same way I would for GET method?  Also, can you think of any reasons why the POST values would not show through, yet the the ones do using GET.    I have always made sure the form action matches the method I am using.

I seem to be having particular problems with passing dates (mysql)  from a search box at the moment.

LVL 16

Expert Comment

ID: 13667556
Sure, welcomes questions

POST and GET actually use the same syntax in both HTML form and PHP server side
The one and only one difference is whether you type GET or POST

So I don't think that the problem is that simple
You may post your code here, so that we can investigate more~~

Further wanna drop a line on the register globals
This one actually provides a shortcut when register_globals are set

You can simply say $account_id and $password to get the GET or POST method parameters

However when register_globals are off, this method crash too~!!

So we will use $_GET ["account_id"] / $_POST ["password"] to get the parameters
And even register_globals are on, these methods works

So that's why for compatibility issue, we will always use $_GET $_POST


Author Comment

ID: 13667602
Thank you very much
LVL 16

Expert Comment

ID: 13667640
You are welcome :)


Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

I still run into .cgi files every now and then. In some instances, I actually prefer the simplicity of a .cgi script to other options. Since I use DreamWeaver extensively, what I needed was a way to open .cgi scripts in Dreamweaver. And I wanted to …
Adobe Dreamweaver CS5 is a WYSIWYG web page editor that has advanced HTML, CSS, and Javascript rendering functionality and is probably the most well-known HTML editor available. Much of Dreamweaver's appeal centers around the Design View interfac…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

765 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