SlideShare a Scribd company logo
GET and POST Methods
The client browser uses two methods to send
information from the client to the web server. These
methods are GET and POST. However, before
sending the information, the browser first encodes
the information using the coding scheme called URL
encoding.
In this coding scheme, key-value pairs, which are
here name-value pairs, which are here name-value
pairs, are combined together in such a way that
different name-value pairs are separated by &
(ampersand). Any whitespaces are replaced by the
plus sign(+) and non-alphanumeric characters are
replaced with their hexadecimal values. Once the
encoding process is over, the data is sent to the web
server. https://phpgurukul.com/get-and-post-
methods/
The GET Method
 When the GET method is used for sending
information to the web server, it sends the same
along with the page URL. The URL is appended
by the encoded information and the question
mark sign (?) separates the former from the
latter. Some of the key things to note about the
use of this method include –
 Since this method appends the page URL, the
sent information will also appear in the logs of
the server.
 The maximum number of characters that can be
sent using the GET method is 1024 characters.
 There is an inherent issue of compromised
confidentiality with this method. Therefore, its use
must be avoided when you are sending
passwords or critical information to the
webserver.
https://phpgurukul.com/get-and-post-
methods/
 Another inherent limitation of the GET
method is that documents and images
cannot be sent to the server using this
method.
 Besides the above-mentioned, it is also
possible to access the data sent using
this method by retrieving the
QUERY_STRING environment
variable. Therefore, data is not safe.
 It is possible to access all the sent
information using this method by
accessing $_GET, which is an
associative array provided by PHP for
this purpose. https://phpgurukul.com/get-and-post-
methods/
<?php
if($_GET[“name”] || $_GET[“age”]){
echo “Welcome”. $_GET[‘name’].”<br />”;
echo “You are”. $_GET[age].”years old”;
exit();
}
<html>
<body>
<form action=”<?php $_PHP_SELF?>”
method=”GET”>
Name: <input type=”text” name=”name” />
Age: <input type=”text” name=”age” />
<input type=”submit”>
</form>
</body>
</html> https://phpgurukul.com/get-and-post-
methods/
The POST Method
 An alternative to the GET method is the POST method. This
method makes uses of HTTP headers to transfer information
from the client to the server. The encoded information is out
into the header. Some of the things that you must know about
the use of this method for information transfer has been listed
below-
 Unlike the GET method, there is no limitation on the number
of characters that can be sent using this method.
 It is possible to send binary as well as ASCII data using this
method.
 As far as the security of data is concerned, data security
totally lies in the hands of the HTTP protocol. You can ensure
higher security of data by using HTTP secure.
 All the data using the POST method can be accessed using
the $_POST associative array.
 You can try the sample code given below to understand how
this method is used.
https://phpgurukul.com/get-and-post-
methods/
<?php
if($_POST[“name”] || $_POST[“age”]){
if(preg_match(“/[^A-Za-z’-]/”,$_POST[‘name’])){
die(“Name is invalid”);
}
echo “Welcome”. $_POST[‘name’].”<br />”;
echo “You are”. $_POST[age].”years old”;
exit();
}
?>
<html>
<body>
<form action=”<?php $_PHP_SELF?>” method=”GET”>
Name: <input type=”text” name=”name” />
Age: <input type=”text” name=”age” />
<input type=”submit”>
</form>
</body>
</hml>
https://phpgurukul.com/get-and-post-
methods/
The $_REQUEST Variable
 The contents of $_GET and $_POST
are available in $_REQUEST. Besides
this, $_REQUEST also contains data
associated with $_COOKIE> The form
data sent to the webserver using both
the methods namely GET and POST
can be accessed by accessing this
variable.
 Here $_PHP_SELF variable contains
the name of the self script in which it is
being called.
https://phpgurukul.com/get-and-post-
methods/
For More Info
Visit: https://phpgurukul.com/get-and-
post-methods/
https://phpgurukul.com/get-and-post-
methods/

More Related Content

PDF
GET and POST in PHP
PPTX
Form Handling using PHP
PPTX
PPT
Get_vs_Post
PDF
Making web forms using php
ODP
Form Processing In Php
PDF
Http methods
GET and POST in PHP
Form Handling using PHP
Get_vs_Post
Making web forms using php
Form Processing In Php
Http methods

What's hot (20)

PDF
21servers And Applets
PPT
KMUTNB - Internet Programming 2/7
PPTX
HTTP request and response
PDF
Forms and Databases in PHP
PDF
RESTful Web Services
PPTX
HTTP Request Header and HTTP Status Code
PPT
How the web works june 2010
PPT
Http request&response by Vignesh 15 MAR 2014
PPTX
Http request and http response
PPTX
SCWCD : The web client model
PPTX
Http headers
PPTX
HTTP fundamentals for developers
PPT
Webbasics
PPT
Php forms
PPT
Session12 J2ME Generic Connection Framework
ODP
PHP Training: Module 1
PPTX
Web (HTTP) request to response life cycle
PPT
Html intake 38 lect1
PDF
Web application technologies
PDF
HTTP Definition and Basics.
21servers And Applets
KMUTNB - Internet Programming 2/7
HTTP request and response
Forms and Databases in PHP
RESTful Web Services
HTTP Request Header and HTTP Status Code
How the web works june 2010
Http request&response by Vignesh 15 MAR 2014
Http request and http response
SCWCD : The web client model
Http headers
HTTP fundamentals for developers
Webbasics
Php forms
Session12 J2ME Generic Connection Framework
PHP Training: Module 1
Web (HTTP) request to response life cycle
Html intake 38 lect1
Web application technologies
HTTP Definition and Basics.
Ad

Similar to Get and post methods in php - phpgurukul (20)

PPTX
5. Formshcfsjhfajkjsfjsjfjksafjsfjkjfhjsafjsajkgfjskafkjas.pptx
PPTX
A179178417_21_2025_PHP Get and Post.pptx
PPTX
Web Techniques like Cookies and Sessions
PDF
PHP-Part4
PPTX
Working with data.pptx
PPTX
forms.pptx
PDF
PHP Making Web Forms
PPT
Lecture7 form processing by okello erick
PPTX
WorkingwithFormsinPHPpptx__2024_10_17_19_07_07 2.pptx
PDF
Form handling in php
PPTX
Unit - III.pptxbgffhjxfjdfjfgjnsnsnshdhsjsksjsjsjsjsjsjsjsjsldksk
PPTX
Unit - III.pptxbgffhjxfjdfjfgjnsnsnshdhsjsksjsjsjsjsjsjsjsjsldksk
PPTX
Working with Data and built-in functions of PHP
PPT
Common Gateway Interface
DOCX
Php forms and validations by naveen kumar veligeti
PPTX
Web Application Development using PHP Chapter 5
PDF
web2_lec6.pdf
PDF
Introduction to php web programming - get and post
ODP
Introduction to Web Programming with Perl
PDF
Web Development Course: PHP lecture 2
5. Formshcfsjhfajkjsfjsjfjksafjsfjkjfhjsafjsajkgfjskafkjas.pptx
A179178417_21_2025_PHP Get and Post.pptx
Web Techniques like Cookies and Sessions
PHP-Part4
Working with data.pptx
forms.pptx
PHP Making Web Forms
Lecture7 form processing by okello erick
WorkingwithFormsinPHPpptx__2024_10_17_19_07_07 2.pptx
Form handling in php
Unit - III.pptxbgffhjxfjdfjfgjnsnsnshdhsjsksjsjsjsjsjsjsjsjsldksk
Unit - III.pptxbgffhjxfjdfjfgjnsnsnshdhsjsksjsjsjsjsjsjsjsjsldksk
Working with Data and built-in functions of PHP
Common Gateway Interface
Php forms and validations by naveen kumar veligeti
Web Application Development using PHP Chapter 5
web2_lec6.pdf
Introduction to php web programming - get and post
Introduction to Web Programming with Perl
Web Development Course: PHP lecture 2
Ad

Recently uploaded (20)

PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
Business Ethics Teaching Materials for college
PDF
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
Basic Mud Logging Guide for educational purpose
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PPTX
Institutional Correction lecture only . . .
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
Insiders guide to clinical Medicine.pdf
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
Week 4 Term 3 Study Techniques revisited.pptx
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Microbial disease of the cardiovascular and lymphatic systems
Business Ethics Teaching Materials for college
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Basic Mud Logging Guide for educational purpose
STATICS OF THE RIGID BODIES Hibbelers.pdf
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
O7-L3 Supply Chain Operations - ICLT Program
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Institutional Correction lecture only . . .
Abdominal Access Techniques with Prof. Dr. R K Mishra
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Insiders guide to clinical Medicine.pdf
FourierSeries-QuestionsWithAnswers(Part-A).pdf
2.FourierTransform-ShortQuestionswithAnswers.pdf
Microbial diseases, their pathogenesis and prophylaxis
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Week 4 Term 3 Study Techniques revisited.pptx
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...

Get and post methods in php - phpgurukul

  • 1. GET and POST Methods The client browser uses two methods to send information from the client to the web server. These methods are GET and POST. However, before sending the information, the browser first encodes the information using the coding scheme called URL encoding. In this coding scheme, key-value pairs, which are here name-value pairs, which are here name-value pairs, are combined together in such a way that different name-value pairs are separated by & (ampersand). Any whitespaces are replaced by the plus sign(+) and non-alphanumeric characters are replaced with their hexadecimal values. Once the encoding process is over, the data is sent to the web server. https://phpgurukul.com/get-and-post- methods/
  • 2. The GET Method  When the GET method is used for sending information to the web server, it sends the same along with the page URL. The URL is appended by the encoded information and the question mark sign (?) separates the former from the latter. Some of the key things to note about the use of this method include –  Since this method appends the page URL, the sent information will also appear in the logs of the server.  The maximum number of characters that can be sent using the GET method is 1024 characters.  There is an inherent issue of compromised confidentiality with this method. Therefore, its use must be avoided when you are sending passwords or critical information to the webserver. https://phpgurukul.com/get-and-post- methods/
  • 3.  Another inherent limitation of the GET method is that documents and images cannot be sent to the server using this method.  Besides the above-mentioned, it is also possible to access the data sent using this method by retrieving the QUERY_STRING environment variable. Therefore, data is not safe.  It is possible to access all the sent information using this method by accessing $_GET, which is an associative array provided by PHP for this purpose. https://phpgurukul.com/get-and-post- methods/
  • 4. <?php if($_GET[“name”] || $_GET[“age”]){ echo “Welcome”. $_GET[‘name’].”<br />”; echo “You are”. $_GET[age].”years old”; exit(); } <html> <body> <form action=”<?php $_PHP_SELF?>” method=”GET”> Name: <input type=”text” name=”name” /> Age: <input type=”text” name=”age” /> <input type=”submit”> </form> </body> </html> https://phpgurukul.com/get-and-post- methods/
  • 5. The POST Method  An alternative to the GET method is the POST method. This method makes uses of HTTP headers to transfer information from the client to the server. The encoded information is out into the header. Some of the things that you must know about the use of this method for information transfer has been listed below-  Unlike the GET method, there is no limitation on the number of characters that can be sent using this method.  It is possible to send binary as well as ASCII data using this method.  As far as the security of data is concerned, data security totally lies in the hands of the HTTP protocol. You can ensure higher security of data by using HTTP secure.  All the data using the POST method can be accessed using the $_POST associative array.  You can try the sample code given below to understand how this method is used. https://phpgurukul.com/get-and-post- methods/
  • 6. <?php if($_POST[“name”] || $_POST[“age”]){ if(preg_match(“/[^A-Za-z’-]/”,$_POST[‘name’])){ die(“Name is invalid”); } echo “Welcome”. $_POST[‘name’].”<br />”; echo “You are”. $_POST[age].”years old”; exit(); } ?> <html> <body> <form action=”<?php $_PHP_SELF?>” method=”GET”> Name: <input type=”text” name=”name” /> Age: <input type=”text” name=”age” /> <input type=”submit”> </form> </body> </hml> https://phpgurukul.com/get-and-post- methods/
  • 7. The $_REQUEST Variable  The contents of $_GET and $_POST are available in $_REQUEST. Besides this, $_REQUEST also contains data associated with $_COOKIE> The form data sent to the webserver using both the methods namely GET and POST can be accessed by accessing this variable.  Here $_PHP_SELF variable contains the name of the self script in which it is being called. https://phpgurukul.com/get-and-post- methods/
  • 8. For More Info Visit: https://phpgurukul.com/get-and- post-methods/ https://phpgurukul.com/get-and-post- methods/