0% found this document useful (0 votes)
185 views10 pages

Get and Post Method in PHP

The document discusses GET and POST methods in PHP for submitting form data to a server. The GET method places data in the URL and has limits, while the POST method hides data and has no limits. The $_REQUEST variable can hold data from GET, POST, or COOKIE. Forms are commonly submitted using POST to hide data from users.

Uploaded by

faraz khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
185 views10 pages

Get and Post Method in PHP

The document discusses GET and POST methods in PHP for submitting form data to a server. The GET method places data in the URL and has limits, while the POST method hides data and has no limits. The $_REQUEST variable can hold data from GET, POST, or COOKIE. Forms are commonly submitted using POST to hide data from users.

Uploaded by

faraz khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Get and Post Methods in

PHP.
Presented By:
Faraz Khan.
Introduction:
PHP provides two methods
through which a client (browser) can send
information to the server. These methods are
given below, and discussed in detail:
 GET method
 POST method

Get and Post Get and Post method are the HTTP.
Method in PHP Request methods used inside the <form> tag
to send form data to the server.
HTTP
HTTP stand for hypertext transfer
protocol. This protocol enables the
communication between the client and the
server where a browser can be the client.
GET Method

The GET method is used to submit the HTML form-data(the form-data is sent to
the page specified in the action attribute). This data is collected by the
predefined $_GET variable for processing.

The information send from an HTML form using the GET method is visible to
everyone in the browser’s address bar, which means that all the variable names
and their values will be displayed in the URL. Therefore, the get method is not
secured to send sensitive information.
Advantages and Disadvantages of GET method
(method = “get”)
Advantages Disadvantages
 You can get bookmark the page with  The GET method should not be used
specific query because the data send while sending any sensitive information.
by the GET method is displayed in  A limited amount of data can be send
URL. using method =“get”. This limit should
 GET method can be cached. not exceed 2048 characters.
 The GET method cannot be used to
 GET requests are always remained in
binary data(such as images or word
the browser history. documents) to the server.
 For security reasons, never use the GET
method to send sensitive information
Like username and password, because it
shows them in the URL.
POST Method

Similar to the GET method, the POST method is also used to submit the HTML
form data. But the data submitted by this method is collected by the predefined
superglobal variable $_POST instead of $_GET.

Unlike the GET method, it does not have a limit on the amount of information
to be send. The information send from an HTML form using the POST method is
not visible to anyone.
Advantages and disadvantages of POST method
(method =“post”)

Advantages Disadvantages
 The POST method is useful for sending  POST requests do not cache.
any sensitive information because the
information send using the POST  POST requests never remain in the
method is not visible to anyone. browser history.
 There is no limitation on size of data to  It is not possible to bookmark the
be send using the POST method. You page because the variables are not
can send a large amount of information displayed in URL.
using this method.
 Binary and ASCII data can also be sent
using the POST method.
$_REQUEST variable

The $_REQUEST variable is a superglobal variable, which can hold the content
of both $_GET and $_POST variable. In other words, the PHP $_REQUEST variable
is used to collect the form data sent by either GET or POST methods. It can also
collect the data for $_COOKIE variable because it is not a method-specific
variable.
FORM Method
POST data is submitted by a form and “posted” to the web server as form data. POST
data is encoded the same way as GET data but isn’t typically visible to the user in standard
browsers.
Most forms use the post method because its “hides” the form data away from the user and
doesn’t clutter up the URL in the address bar. Note that GET and POST methods are
equally (in)secure.
Summary
 Forms are used to get data from the users.
 Forms are created using HTML tags.
 Forms can be submitted to the server for processing using either POST or GET method.
Form Handling process.

You might also like