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 rollback specific migration in laravel

How to rollback specific migration in laravel ?

March 6, 2022February 8, 2024

In this article we will learn rollback specific migration in laravel, in our recent article i wrote about creating migration in laravel and sometimes after creating migration we want to rollback specific migration laravel so in this article i will show you to rollback a specific migration in laravel. Laravel…

Read More
Laravel Call Controller Method from Another Controller in Laravel

How to Call Controller Method from Another Controller in Laravel ?

December 2, 2023March 16, 2024

In this article we will learn Call Controller Method from Another Controller in Laravel. Sometimes we need to access the controller method from another controller to save the same code on multiple locations. Best way to achieve it is using create a separate service class or trait in PHP so…

Read More
Uncategorized Laravel ajax form with example

Submit form using jQuery in Laravel

November 18, 2021November 18, 2021

jQuery is most popular library to handle the client side events like form submit, click, change etc. In this article we will learn to submit the form using jQuery Ajax method. Ajax is mostly used when we do not want to reload the page and real time interaction. In this…

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

  • 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

  • Understanding High Vulnerabilities: A Deep Dive into Recent Security Concerns
  • Understanding High Vulnerabilities in Software: A Week of Insights
  • Blocking Spam Requests with LaraGuard IP: A Comprehensive Guide
  • Enhancing API Development with Laravel API Kit
  • Exploring the Future of Web Development: Insights from Milana Cap
©2023 Readerstacks | Design and Developed by Readerstacks
Go to mobile version