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

What is httpd.conf and httpd-vhost.conf file in apache?

August 28, 2021August 28, 2021

https.conf is main file of apache web server to handle the requests. Apache httpd.conf file generally located at /etc/httpd/conf/httpd, /etc/apache2/ , /etc/apache2/sites-enabled/ in ubuntu. httpd.conf contains the information of server root and port used routing. httpd-vhost contains additional information of virtual host.

Read More

Laravel view – A complete guide for beginner

December 8, 2021December 8, 2021

Laravel view is the presentation layer of laravel. Views are used to show the html and keep separate controller login from view logic. We can created nested views, dynamic views to show dynamic data, include another view in a view. It’s not practical to use a long html in controller…

Read More
Uncategorized confirm password validation in Laravel

Password and confirm password validation in Laravel

January 26, 2022November 10, 2023

There is many ways to check the password and confirm password validation in laravel. we can match password using the equals to operator but in that case we need to work as core PHP. So In laravel we have Validation library to create the validation rules. Laravel itself provides multiple…

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