SlideShare une entreprise Scribd logo
1  sur  6
Télécharger pour lire hors ligne
PHP Tutorials By Vineet Kumar Saini

                        $_GET and $_POST in PHP

Introduction

Using the GET and POST methods, the browser client can send data to the web server. In
PHP the GET and POST methods are used to retrieve information from forms, such as user
input. Get and Post are methods used to send data to the server. These methods are used
for data handling in forms. Where each method varies a little in the way they work.

GET Method

In the GET method, we can also send data to the server. But when using the GET method
we can't send the login details with a password because it is less secure (information sent
from a form with the GET method is visible to everyone). We can say that the GET method
is for getting something from the server; it doesn't mean that you cannot send a parameter
to the server.

The main points about the GET method are as follows:

      The GET method is used to collect values in a form.
      GET method is used when the URL is sent to the server.
      GET method has limits on the amount of information to send because URL lengths
       are limited.
      The Get method is used to retrieve web pages from the server.
      The GET method is the default method for many browsers.
      Data is sent as a part of the URL in 'name-value' pairs.
      In the GET method page and the encoded information are separated by the question
       mark (?) sign.
      In the GET method, the browser appends the data onto the URL.
      The Get method is less secure because information sent from a form with the GET
       method is visible to everyone (it will be displayed in the browser's address bar) .
      GET can't be used to send binary data, like images or word documents, to the
       server.

Example

First of all we create a PHP file which is called by the HTML page in later.

<html>
<body bgcolor="pink">
Welcome <?php echo $_GET ["Name"]; ?>.<br/>
You are <?php echo $_GET ["Class"]; ?> Qualified !!
</body>
</html>

The above file is to be saved with the name "get.php", which is called by the HTML page
later.

<html>
<body bgcolor="pink"><table>
PHP Tutorials By Vineet Kumar Saini

<form action="get.php" method="get">
<tr><td>Name: <input type="text" name="Name" /></td></tr>
<tr><td>Class : <input type="text" name="Class" /></td></tr>
<input type="submit" " value="Submit"/>
</form>
</body>
</html>

This file is saved as "get.html". In this file get.php is called.

Output

You will put the URL in the web browser like as: http://localhost/FolderName/get.html.




Now you will fill text like as name and class. When you click on the submit button then you
will see your browser URL changed. You can see in the following image.
PHP Tutorials By Vineet Kumar Saini

POST Method

In PHP $_POST variable is used to collect values from a form sent with method="post". In
the POST method one can request as well as send some data to the server. The POST
method is used when one can send a long enquiry form. Using the POST method the login
details with password can be posted because it is secure (information sent from a form with
the POST method is invisible to everyone).

The main points about POST method are as follows:

      The POST method is used to collect values from a form.
      The POST method has no limits on the amount of information to send because URL
       lengths are unlimited.
      The POST method is the not default method for many browsers.
      In the POST method, the page and the encoded information are not separated by the
       question mark (?) sign.
      In the POST method, the browser doesn't append the data onto the URL.
      The POST method is secure because information sent from a form with the GET
       method is invisible to everyone.
      The POST method can be used to send binary data, like images or Word documents,
       to the server.
      In the POST method, the data is sent as standard input.
      The POST method is slower than the GET method.
      PHP provides the $_POST associative array to access all the information sent using
       the GET method.

Example

First of all we create a PHP file which is called by the HTML page later.

<html>
<body bgcolor="pink">
Welcome <?php echo $_POST ["Name"]; ?>.<br/>
You are <?php echo $_POST ["Class"]; ?> Qualified !!
</body>
</html>

The above file is saved with the "post.php" name, which is called by the HTML page later.

<html>
<body bgcolor="pink">
<table>
<form action="post.php" method="post">
<tr><td>Name: <input type="text" name="Name" /></td></tr>
<tr><td>Class : <input type="text" name="Class" /></td></tr>
<input type="submit" " value="Submit"/>
</form>
</body>
</html>

This file is saved as "post.html". In this file post.php is called.
PHP Tutorials By Vineet Kumar Saini




Now you will fill text like as name and class. When you click on the submit button then you
will see your browser URL is not changed. You can see in the following image.




$_REQUEST Variable

The $_REQUEST variable is also used to send data to the server. The $_REQUEST variable is
a predefined variable in PHP. Which keeps the $_GET, $_POST and also $_Cookie variable.
This variable is used to collect data of the form sent by the GET and POST methods.

First of all we create a PHP file which is called by the HTML page later.

<html>
<body bgcolor="pink">
Welcome <?php echo $_REQUEST ["Name"]; ?>.<br/>
You are <?php echo $_REQUEST ["Class"]; ?> Qualified !!
PHP Tutorials By Vineet Kumar Saini

</body>
</html>

The above file is saved with the "request.php" name, which is called by the HTML page
later.

<html>
<body bgcolor="pink">
<table>
<form action="request.php" method="post">
<tr><td>Name: <input type="text" name="Name" /></td></tr>
<tr><td>Class : <input type="text" name="Class" /></td></tr>
<input type="submit" " value="Submit"/>
</form>
</body>
</html>

This file is save as "request.html". In this file post.php is called.




If we use the POST method then the URL of the browser is not append. You can see in
the following image.
PHP Tutorials By Vineet Kumar Saini




If we use the GET method then the URL of the browser is changed. You can see in the
following image.




Conclusion

So in this article you saw the differences between the GET and POST methods in PHP.

Contenu connexe

Tendances (20)

HTTP request and response
HTTP request and responseHTTP request and response
HTTP request and response
 
PHP Cookies and Sessions
PHP Cookies and SessionsPHP Cookies and Sessions
PHP Cookies and Sessions
 
Sessions in php
Sessions in php Sessions in php
Sessions in php
 
Php sessions & cookies
Php sessions & cookiesPhp sessions & cookies
Php sessions & cookies
 
Php and MySQL
Php and MySQLPhp and MySQL
Php and MySQL
 
Php sessions
Php sessionsPhp sessions
Php sessions
 
laravel.pptx
laravel.pptxlaravel.pptx
laravel.pptx
 
Php mysql ppt
Php mysql pptPhp mysql ppt
Php mysql ppt
 
Form Handling using PHP
Form Handling using PHPForm Handling using PHP
Form Handling using PHP
 
PHP
PHPPHP
PHP
 
HTML Forms
HTML FormsHTML Forms
HTML Forms
 
Php with mysql ppt
Php with mysql pptPhp with mysql ppt
Php with mysql ppt
 
Arrays in PHP
Arrays in PHPArrays in PHP
Arrays in PHP
 
Java Server Pages
Java Server PagesJava Server Pages
Java Server Pages
 
Database Connectivity in PHP
Database Connectivity in PHPDatabase Connectivity in PHP
Database Connectivity in PHP
 
Php forms and validations by naveen kumar veligeti
Php forms and validations by naveen kumar veligetiPhp forms and validations by naveen kumar veligeti
Php forms and validations by naveen kumar veligeti
 
Php string function
Php string function Php string function
Php string function
 
Php.ppt
Php.pptPhp.ppt
Php.ppt
 
Html
HtmlHtml
Html
 
Introduction to HTML5
Introduction to HTML5Introduction to HTML5
Introduction to HTML5
 

En vedette

AT COMMAND SET FOR SENDING DATA VIA TCP USING SIM900
AT COMMAND SET FOR SENDING DATA VIA TCP USING SIM900AT COMMAND SET FOR SENDING DATA VIA TCP USING SIM900
AT COMMAND SET FOR SENDING DATA VIA TCP USING SIM900Devrhoid Davis
 
Getting Started with SainSmart SIM900 GPRS (Autosaved)
Getting Started with SainSmart SIM900 GPRS (Autosaved)Getting Started with SainSmart SIM900 GPRS (Autosaved)
Getting Started with SainSmart SIM900 GPRS (Autosaved)Devrhoid Davis
 
GSM GPRS SIM900A Modem
GSM GPRS SIM900A ModemGSM GPRS SIM900A Modem
GSM GPRS SIM900A ModemRaghav Shetty
 
2014 App Dev Confr. - iBeacons, BLE Beacons and Everything in Between.
2014 App Dev Confr. - iBeacons, BLE Beacons and Everything in Between.2014 App Dev Confr. - iBeacons, BLE Beacons and Everything in Between.
2014 App Dev Confr. - iBeacons, BLE Beacons and Everything in Between.John Donohoe
 
About BLE server profile
About BLE server profile About BLE server profile
About BLE server profile Lin Steven
 
Ble overview and_implementation
Ble overview and_implementationBle overview and_implementation
Ble overview and_implementationStanley Chang
 
The Internet of Things: BLE / Beacons / iBeacons
The Internet of Things: BLE / Beacons / iBeaconsThe Internet of Things: BLE / Beacons / iBeacons
The Internet of Things: BLE / Beacons / iBeaconsVectorform
 
Bluetooth low energy(ble) wireless technology
Bluetooth low energy(ble) wireless technologyBluetooth low energy(ble) wireless technology
Bluetooth low energy(ble) wireless technologyLin Steven
 
Gsm based campus display system project report
Gsm based campus display system project reportGsm based campus display system project report
Gsm based campus display system project reportKashyap Shah
 
PHP Technical Questions
PHP Technical QuestionsPHP Technical Questions
PHP Technical QuestionsPankaj Jha
 
Top 100 PHP Interview Questions and Answers
Top 100 PHP Interview Questions and AnswersTop 100 PHP Interview Questions and Answers
Top 100 PHP Interview Questions and AnswersVineet Kumar Saini
 

En vedette (20)

AT COMMAND SET FOR SENDING DATA VIA TCP USING SIM900
AT COMMAND SET FOR SENDING DATA VIA TCP USING SIM900AT COMMAND SET FOR SENDING DATA VIA TCP USING SIM900
AT COMMAND SET FOR SENDING DATA VIA TCP USING SIM900
 
Getting Started with SainSmart SIM900 GPRS (Autosaved)
Getting Started with SainSmart SIM900 GPRS (Autosaved)Getting Started with SainSmart SIM900 GPRS (Autosaved)
Getting Started with SainSmart SIM900 GPRS (Autosaved)
 
GSM GPRS SIM900A Modem
GSM GPRS SIM900A ModemGSM GPRS SIM900A Modem
GSM GPRS SIM900A Modem
 
SQL Limit in PHP
SQL Limit in PHPSQL Limit in PHP
SQL Limit in PHP
 
CSS in HTML
CSS in HTMLCSS in HTML
CSS in HTML
 
Browser information in PHP
Browser information in PHPBrowser information in PHP
Browser information in PHP
 
Programming in C
Programming in CProgramming in C
Programming in C
 
Pagination in PHP
Pagination in PHPPagination in PHP
Pagination in PHP
 
MVC in PHP
MVC in PHPMVC in PHP
MVC in PHP
 
2014 App Dev Confr. - iBeacons, BLE Beacons and Everything in Between.
2014 App Dev Confr. - iBeacons, BLE Beacons and Everything in Between.2014 App Dev Confr. - iBeacons, BLE Beacons and Everything in Between.
2014 App Dev Confr. - iBeacons, BLE Beacons and Everything in Between.
 
About BLE server profile
About BLE server profile About BLE server profile
About BLE server profile
 
Most usefull at commands
Most usefull at commandsMost usefull at commands
Most usefull at commands
 
Ble overview and_implementation
Ble overview and_implementationBle overview and_implementation
Ble overview and_implementation
 
Sim900
Sim900Sim900
Sim900
 
The Internet of Things: BLE / Beacons / iBeacons
The Internet of Things: BLE / Beacons / iBeaconsThe Internet of Things: BLE / Beacons / iBeacons
The Internet of Things: BLE / Beacons / iBeacons
 
Bluetooth low energy(ble) wireless technology
Bluetooth low energy(ble) wireless technologyBluetooth low energy(ble) wireless technology
Bluetooth low energy(ble) wireless technology
 
Gsm based campus display system project report
Gsm based campus display system project reportGsm based campus display system project report
Gsm based campus display system project report
 
Practice exam php
Practice exam phpPractice exam php
Practice exam php
 
PHP Technical Questions
PHP Technical QuestionsPHP Technical Questions
PHP Technical Questions
 
Top 100 PHP Interview Questions and Answers
Top 100 PHP Interview Questions and AnswersTop 100 PHP Interview Questions and Answers
Top 100 PHP Interview Questions and Answers
 

Similaire à GET and POST in PHP

Get and post methods in php - phpgurukul
Get and post methods in php  - phpgurukulGet and post methods in php  - phpgurukul
Get and post methods in php - phpgurukulPHPGurukul Blog
 
Lecture7 form processing by okello erick
Lecture7 form processing by okello erickLecture7 form processing by okello erick
Lecture7 form processing by okello erickokelloerick
 
Web Development Course: PHP lecture 2
Web Development Course: PHP lecture 2Web Development Course: PHP lecture 2
Web Development Course: PHP lecture 2Gheyath M. Othman
 
Web app development_php_07
Web app development_php_07Web app development_php_07
Web app development_php_07Hassen Poreya
 
Form handling in php
Form handling in phpForm handling in php
Form handling in phpFahad Khan
 
Class 6 - PHP Web Programming
Class 6 - PHP Web ProgrammingClass 6 - PHP Web Programming
Class 6 - PHP Web ProgrammingAhmed Swilam
 
Web Application Development using PHP Chapter 5
Web Application Development using PHP Chapter 5Web Application Development using PHP Chapter 5
Web Application Development using PHP Chapter 5Mohd Harris Ahmad Jaal
 
Working with data.pptx
Working with data.pptxWorking with data.pptx
Working with data.pptxSherinRappai
 
Introduction to web development - HTML 5
Introduction to web development - HTML 5Introduction to web development - HTML 5
Introduction to web development - HTML 5Ayoub Ghozzi
 
Chapter 1.Web Techniques_Notes.pptx
Chapter 1.Web Techniques_Notes.pptxChapter 1.Web Techniques_Notes.pptx
Chapter 1.Web Techniques_Notes.pptxShitalGhotekar
 
PHP Forms PHP 05
PHP Forms PHP 05PHP Forms PHP 05
PHP Forms PHP 05Spy Seat
 

Similaire à GET and POST in PHP (20)

Making web forms using php
Making web forms using phpMaking web forms using php
Making web forms using php
 
Introduction to php web programming - get and post
Introduction to php  web programming - get and postIntroduction to php  web programming - get and post
Introduction to php web programming - get and post
 
PHP-Part4
PHP-Part4PHP-Part4
PHP-Part4
 
Get and post methods in php - phpgurukul
Get and post methods in php  - phpgurukulGet and post methods in php  - phpgurukul
Get and post methods in php - phpgurukul
 
Get method and post method
Get method and post methodGet method and post method
Get method and post method
 
Lecture7 form processing by okello erick
Lecture7 form processing by okello erickLecture7 form processing by okello erick
Lecture7 form processing by okello erick
 
Web Development Course: PHP lecture 2
Web Development Course: PHP lecture 2Web Development Course: PHP lecture 2
Web Development Course: PHP lecture 2
 
PHP Making Web Forms
PHP Making Web FormsPHP Making Web Forms
PHP Making Web Forms
 
Web app development_php_07
Web app development_php_07Web app development_php_07
Web app development_php_07
 
Form handling in php
Form handling in phpForm handling in php
Form handling in php
 
Class 6 - PHP Web Programming
Class 6 - PHP Web ProgrammingClass 6 - PHP Web Programming
Class 6 - PHP Web Programming
 
forms.pptx
forms.pptxforms.pptx
forms.pptx
 
Sessions n cookies
Sessions n cookiesSessions n cookies
Sessions n cookies
 
Web Application Development using PHP Chapter 5
Web Application Development using PHP Chapter 5Web Application Development using PHP Chapter 5
Web Application Development using PHP Chapter 5
 
Working with data.pptx
Working with data.pptxWorking with data.pptx
Working with data.pptx
 
Introduction to web development - HTML 5
Introduction to web development - HTML 5Introduction to web development - HTML 5
Introduction to web development - HTML 5
 
Session and cookies ,get and post methods
Session and cookies ,get and post methodsSession and cookies ,get and post methods
Session and cookies ,get and post methods
 
Chapter 1.Web Techniques_Notes.pptx
Chapter 1.Web Techniques_Notes.pptxChapter 1.Web Techniques_Notes.pptx
Chapter 1.Web Techniques_Notes.pptx
 
Get and post methods
Get and post methodsGet and post methods
Get and post methods
 
PHP Forms PHP 05
PHP Forms PHP 05PHP Forms PHP 05
PHP Forms PHP 05
 

Plus de Vineet Kumar Saini (20)

Abstract Class and Interface in PHP
Abstract Class and Interface in PHPAbstract Class and Interface in PHP
Abstract Class and Interface in PHP
 
Add edit delete in Codeigniter in PHP
Add edit delete in Codeigniter in PHPAdd edit delete in Codeigniter in PHP
Add edit delete in Codeigniter in PHP
 
Introduction to Html
Introduction to HtmlIntroduction to Html
Introduction to Html
 
Computer Fundamentals
Computer FundamentalsComputer Fundamentals
Computer Fundamentals
 
Country State City Dropdown in PHP
Country State City Dropdown in PHPCountry State City Dropdown in PHP
Country State City Dropdown in PHP
 
Stripe in php
Stripe in phpStripe in php
Stripe in php
 
Php Tutorials for Beginners
Php Tutorials for BeginnersPhp Tutorials for Beginners
Php Tutorials for Beginners
 
Install Drupal on Wamp Server
Install Drupal on Wamp ServerInstall Drupal on Wamp Server
Install Drupal on Wamp Server
 
Joomla 2.5 Tutorial For Beginner PDF
Joomla 2.5 Tutorial For Beginner PDFJoomla 2.5 Tutorial For Beginner PDF
Joomla 2.5 Tutorial For Beginner PDF
 
Functions in PHP
Functions in PHPFunctions in PHP
Functions in PHP
 
Sorting arrays in PHP
Sorting arrays in PHPSorting arrays in PHP
Sorting arrays in PHP
 
Dropdown List in PHP
Dropdown List in PHPDropdown List in PHP
Dropdown List in PHP
 
Update statement in PHP
Update statement in PHPUpdate statement in PHP
Update statement in PHP
 
Delete statement in PHP
Delete statement in PHPDelete statement in PHP
Delete statement in PHP
 
Implode & Explode in PHP
Implode & Explode in PHPImplode & Explode in PHP
Implode & Explode in PHP
 
Types of Error in PHP
Types of Error in PHPTypes of Error in PHP
Types of Error in PHP
 
Database connectivity in PHP
Database connectivity in PHPDatabase connectivity in PHP
Database connectivity in PHP
 
Arrays in PHP
Arrays in PHPArrays in PHP
Arrays in PHP
 
Operators in PHP
Operators in PHPOperators in PHP
Operators in PHP
 
Variables in PHP
Variables in PHPVariables in PHP
Variables in PHP
 

Dernier

ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)cama23
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptxiammrhaywood
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxCulture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxPoojaSen20
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 

Dernier (20)

ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxCulture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 

GET and POST in PHP

  • 1. PHP Tutorials By Vineet Kumar Saini $_GET and $_POST in PHP Introduction Using the GET and POST methods, the browser client can send data to the web server. In PHP the GET and POST methods are used to retrieve information from forms, such as user input. Get and Post are methods used to send data to the server. These methods are used for data handling in forms. Where each method varies a little in the way they work. GET Method In the GET method, we can also send data to the server. But when using the GET method we can't send the login details with a password because it is less secure (information sent from a form with the GET method is visible to everyone). We can say that the GET method is for getting something from the server; it doesn't mean that you cannot send a parameter to the server. The main points about the GET method are as follows:  The GET method is used to collect values in a form.  GET method is used when the URL is sent to the server.  GET method has limits on the amount of information to send because URL lengths are limited.  The Get method is used to retrieve web pages from the server.  The GET method is the default method for many browsers.  Data is sent as a part of the URL in 'name-value' pairs.  In the GET method page and the encoded information are separated by the question mark (?) sign.  In the GET method, the browser appends the data onto the URL.  The Get method is less secure because information sent from a form with the GET method is visible to everyone (it will be displayed in the browser's address bar) .  GET can't be used to send binary data, like images or word documents, to the server. Example First of all we create a PHP file which is called by the HTML page in later. <html> <body bgcolor="pink"> Welcome <?php echo $_GET ["Name"]; ?>.<br/> You are <?php echo $_GET ["Class"]; ?> Qualified !! </body> </html> The above file is to be saved with the name "get.php", which is called by the HTML page later. <html> <body bgcolor="pink"><table>
  • 2. PHP Tutorials By Vineet Kumar Saini <form action="get.php" method="get"> <tr><td>Name: <input type="text" name="Name" /></td></tr> <tr><td>Class : <input type="text" name="Class" /></td></tr> <input type="submit" " value="Submit"/> </form> </body> </html> This file is saved as "get.html". In this file get.php is called. Output You will put the URL in the web browser like as: http://localhost/FolderName/get.html. Now you will fill text like as name and class. When you click on the submit button then you will see your browser URL changed. You can see in the following image.
  • 3. PHP Tutorials By Vineet Kumar Saini POST Method In PHP $_POST variable is used to collect values from a form sent with method="post". In the POST method one can request as well as send some data to the server. The POST method is used when one can send a long enquiry form. Using the POST method the login details with password can be posted because it is secure (information sent from a form with the POST method is invisible to everyone). The main points about POST method are as follows:  The POST method is used to collect values from a form.  The POST method has no limits on the amount of information to send because URL lengths are unlimited.  The POST method is the not default method for many browsers.  In the POST method, the page and the encoded information are not separated by the question mark (?) sign.  In the POST method, the browser doesn't append the data onto the URL.  The POST method is secure because information sent from a form with the GET method is invisible to everyone.  The POST method can be used to send binary data, like images or Word documents, to the server.  In the POST method, the data is sent as standard input.  The POST method is slower than the GET method.  PHP provides the $_POST associative array to access all the information sent using the GET method. Example First of all we create a PHP file which is called by the HTML page later. <html> <body bgcolor="pink"> Welcome <?php echo $_POST ["Name"]; ?>.<br/> You are <?php echo $_POST ["Class"]; ?> Qualified !! </body> </html> The above file is saved with the "post.php" name, which is called by the HTML page later. <html> <body bgcolor="pink"> <table> <form action="post.php" method="post"> <tr><td>Name: <input type="text" name="Name" /></td></tr> <tr><td>Class : <input type="text" name="Class" /></td></tr> <input type="submit" " value="Submit"/> </form> </body> </html> This file is saved as "post.html". In this file post.php is called.
  • 4. PHP Tutorials By Vineet Kumar Saini Now you will fill text like as name and class. When you click on the submit button then you will see your browser URL is not changed. You can see in the following image. $_REQUEST Variable The $_REQUEST variable is also used to send data to the server. The $_REQUEST variable is a predefined variable in PHP. Which keeps the $_GET, $_POST and also $_Cookie variable. This variable is used to collect data of the form sent by the GET and POST methods. First of all we create a PHP file which is called by the HTML page later. <html> <body bgcolor="pink"> Welcome <?php echo $_REQUEST ["Name"]; ?>.<br/> You are <?php echo $_REQUEST ["Class"]; ?> Qualified !!
  • 5. PHP Tutorials By Vineet Kumar Saini </body> </html> The above file is saved with the "request.php" name, which is called by the HTML page later. <html> <body bgcolor="pink"> <table> <form action="request.php" method="post"> <tr><td>Name: <input type="text" name="Name" /></td></tr> <tr><td>Class : <input type="text" name="Class" /></td></tr> <input type="submit" " value="Submit"/> </form> </body> </html> This file is save as "request.html". In this file post.php is called. If we use the POST method then the URL of the browser is not append. You can see in the following image.
  • 6. PHP Tutorials By Vineet Kumar Saini If we use the GET method then the URL of the browser is changed. You can see in the following image. Conclusion So in this article you saw the differences between the GET and POST methods in PHP.