Types Of Request Methods.
GET METHOD
The predefined $_GET variable is
used to collect values in a form with method="get".
Information
sent from a form with the GET method is visible to everyone (it will be
displayed in the browser's address bar) and has limits on the amount of
information to send.
·
The GET method
produces a long string that appears
in your server logs, in the browser's Location: box.
·
The GET method is restricted to send up to 1024 characters only.
·
Never use GET method if you have password or other sensitive
information to be sent to theserver.
·
GET can't be used to send binary data, like images or word documents,
to the server.
·
The data sent by GET method can be accessed using QUERY_STRING
environment variable.
·
The PHP provides $_GET associative array to access all the sent
information using GET method.
Example:
When the user clicks the
"Submit" button, the URL sent to the server could look something like
this:
The
"welcome.php" file can now use the $_GET variable to collect form
data (the names of the form fields will automatically be the keys in the $_GET
array):
POST METHOD
In PHP, the predefined $_POST
variable is used to collect values in a form with method="post". The
predefined $_POST variable is used to collect values from a form sent with
method="post".
Information sent from a form
with the POST method is invisible to others and has no limits on the amount of information
to send.
Example:
When the user clicks the
"Submit" button, the URL sent to the server could look something like
this:
The "welcome.php" file
can now use the $_POST variable to collect form data (the names of the form
fields will automatically be the keys in the $_GET array):
When to use method="post"?
Information
sent from a form with the POST method is invisible to others and has no limits
on the amount of information to send.
However, because the variables are not displayed in the URL, it is not
possible to bookmark the page.
No comments:
Post a Comment