Skip to content
Readerstacks logo Readerstacks
  • Home
  • Softwares
  • Angular
  • Php
  • Laravel
  • Flutter
Readerstacks logo
Readerstacks
Request Method

Difference between $_POST $_GET and $_REQUEST in PHP

Aman Jain, August 19, 2021November 8, 2023

PHP gives there is 3 types of request methods to by which client can send information to server. In this article we will learn difference in get vs post and also in request. So, Methods are as follow

  1. $_POST
  2. $_GET
  3. $_REQUEST

1. $_POST Request Method

$_POST is used to fetch the post request data from the client end.

Example of client and server request in php

<form action="/action_page.php" method="post">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
   
  <input type="submit" value="Submit">
</form>

File: index.php

<?php 
$first_name = $_POST['fname'];

File: action_page.php

2. $_GET Request Method

$_GET is used to fetch the query params from URL and form.

<form action="/action_page.php" method="get"> // here method is get
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
   
  <input type="submit" value="Submit">
</form>

we can also use it in URL

https://your_url.com/index.php?post=115&action=edit

In php

<?php 

$first_name = $_GET['fname'];  //form index.php
//url
$post= $_GET["post"];

$action=$GTE["action"];

File: action_page.php

3. $_REQUEST Method

$_REQUEST is combination of both $_GET and $_POST. so we can fetch both type of request using $_REQUEST.

<?php 

$first_name = $_REQUEST['fname'];  //form index.php

//url
$post= $_REQUEST["post"];

$action=$_REQUEST["action"];

Difference between GET vs POST

Here is table for get vs post

GETPOST
BACK button/ReloadNo LossPost Data will resubmit
BookmarkedWe can bookmark easilyCannot
CachedYesNo
Encoding typeapplication/x-www-form-urlencodedapplication/x-www-form-urlencoded or multipart/form-data. Use multipart encoding for binary data
HistoryParameters stay in urlLost
Restrictions on data lengthYes, maximum URL length is 2048 charactersNo restrictions
Restrictions on data typeOnly ASCII characters allowedNo restrictions
SecurityLessHigh
VisibilityYes, visible in urlNo
Difference between get and post

Difference between $_GET and $_REQUEST

As i mentioned above $_REQUEST is combination of both post and get. Hence, its only exist in PHP and can be used as both get and posy methods.

Also Read : How to connect PHP to MySQL ?

Related

Uncategorized

Post navigation

Previous post
Next post

Related Posts

Uncategorized Laravel database transactions

How to use database transaction in laravel eloquent with example ?

January 1, 2022February 22, 2024

Database Laravel Transaction in laravel eloquent are used to execute multiple or single database operations which maintainer ACID(atomicity, consistency, isolation, and durability) property of transactions. In laravel we can archive the database transaction by DB facade. Laravel DB facade provides two methods to handle the transactions one through DB::transaction() method…

Read More
Laravel Create database connection in laravel

How to make database connection in Laravel 8 ?

December 14, 2021February 22, 2024

Laravel comes with first party support for several database drivers. Laravel gives much better flexibility in terms of using the RDBMS based databases. Laravel supports MySQL, PostgreSQL, SQLite and SQL Server by default but if you want to make connection with Mongo or other database then you need to install…

Read More
Uncategorized Custom middleware in laravel

How to create custom middleware Laravel 8

October 15, 2021November 6, 2023

In this tutorial we will going to learn custom middleware Laravel 8. Middleware are used to create a layer between request and response of the http request. it filters or create a logic before the request serve to the controller and also filter or modify the response. we can also…

Read More

Aman Jain
Aman Jain

With years of hands-on experience in the realm of web and mobile development, they have honed their skills in various technologies, including Laravel, PHP CodeIgniter, mobile app development, web app development, Flutter, React, JavaScript, Angular, Devops and so much more. Their proficiency extends to building robust REST APIs, AWS Code scaling, and optimization, ensuring that your applications run seamlessly on the cloud.

Categories

  • Angular
  • CSS
  • Dart
  • Devops
  • Flutter
  • HTML
  • Javascript
  • jQuery
  • Laravel
  • Laravel 10
  • Laravel 11
  • Laravel 9
  • Mysql
  • Php
  • Softwares
  • Ubuntu
  • Uncategorized

Archives

  • June 2025
  • May 2025
  • April 2025
  • October 2024
  • July 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
  • July 2023
  • March 2023
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021

Recent Posts

  • The Resilience of Nature: How Forests Recover After Fires
  • Understanding Laravel Cookie Consent for GDPR Compliance
  • Understanding High Vulnerabilities: A Critical Overview of the Week of May 12, 2025
  • Installing a LAMP Stack on Ubuntu: A Comprehensive Guide
  • Understanding High Vulnerabilities: A Deep Dive into Recent Security Concerns
©2023 Readerstacks | Design and Developed by Readerstacks
Go to mobile version