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

Difference between $_GET & _POST with forms

Hello

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.
0
debbieau1
Asked:
debbieau1
  • 3
  • 2
1 Solution
 
vickerleungCommented:
debbieau1

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

GET
- 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

POST
- 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
Vicker
0
 
debbieau1Author Commented:
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.


0
 
vickerleungCommented:
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

Vicker
0
 
debbieau1Author Commented:
Thank you very much
0
 
vickerleungCommented:
You are welcome :)

Vicker
0

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.

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