PHP php input vs POST

0 votes
I want to know what is the benefits of using this vs the global method of $_POST or $_GET?
Jun 9, 2022 in PHP by Kichu
• 19,040 points
732 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

The PHP superglobal $_POST, only is supposed to wrap data that is either.

  • application/x-www-form-urlencoded (standard content type for simple form-posts) or
  • multipart/form-data (mostly used for file uploads)

If you simply POST a good old HTML form, the request looks something like this:

POST /page.php HTTP/1.1

key1=value1&key2=value2&key3=value3

The server and PHP traditionally don't expect to receive any other content type.  In most cases, JSON is the best choice. But a request with a JSON payload would look something like this:

POST /page.php HTTP/1.1

{"key1":"value1","key2":"value2","key3":"value3"}

So php://input returns all the raw data after the HTTP headers of the request, regardless of the content type.

I hope this helps you.

answered Jun 11, 2022 by narikkadan
• 63,600 points

edited Mar 5

Related Questions In PHP

0 votes
1 answer

How do I remove http, https and slash from user input in php

Hello @kartik, Use: $url = preg_replace("(^https?://)", "", $url ); This ...READ MORE

answered Nov 19, 2020 in PHP by Niroj
• 82,840 points
2,879 views
0 votes
1 answer

How to get input value in PHP ?

Hello, Use PHP's $_POST or $_GET superglobals to retrieve the value of ...READ MORE

answered Nov 20, 2020 in PHP by Niroj
• 82,840 points
75,328 views
0 votes
0 answers

php var_dump() vs print_r()

What is the difference between var_dump() and print_r() in terms of ...READ MORE

May 28, 2022 in PHP by Kichu
• 19,040 points
605 views
0 votes
0 answers

PHP | define() vs. const

In PHP, there are two ways to ...READ MORE

Jun 1, 2022 in PHP by Kichu
• 19,040 points
1,043 views
0 votes
0 answers

Multiple Image Upload PHP form with one input

I want to have multiple image upload forms ...READ MORE

Jun 13, 2022 in PHP by narikkadan
• 63,600 points
712 views
0 votes
0 answers

file_get_contents("php://input") or $HTTP_RAW_POST_DATA, which one is better to get the body of JSON request?

The file_get_contents("php://input") or $HTTP_RAW_POST_DATA - which one ...READ MORE

Jun 23, 2022 in PHP by narikkadan
• 63,600 points
1,310 views
0 votes
0 answers

Edit PHP query code depending on image map clicked area using AJAX

I am working on an image map ...READ MORE

Jun 3, 2022 in PHP by Kichu
• 19,040 points
507 views
0 votes
0 answers

Fetch data from database in php through AJAX,

The index.php  I created a connection with the ...READ MORE

Jun 16, 2022 in PHP by narikkadan
• 63,600 points
8,448 views
0 votes
0 answers

Using Jquery Ajax to retrieve data from Mysql

list.php: A simple ajax code that I ...READ MORE

Jun 20, 2022 in PHP by Kithuzzz
• 38,000 points
1,006 views
0 votes
1 answer

Using Jquery Ajax to retrieve data from Mysql

You forgot the table tag Write echo"<table>" before ...READ MORE

answered Dec 30, 2022 in Web Development by anonymous

edited Mar 5 23,600 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP