» » POST data reception mode in PHP

 

POST data reception mode in PHP

Author: bamboo06 on 8-08-2015, 01:42, views: 6682

3
Typically the user to use the browser web form to submit data to the server post, we use PHP receiving user data POST to the server, and appropriate treatment. But in some cases, such as the user using the client software to send data to the server-side post php program, rather than using $ _POST to identify, then how should we handle it?
POST data reception mode in PHP

$ _POST Receive data
$ _POST Is an array variable is passed by way of HTTP POST method consisting of automatic global variable. Such as using $ _POST ['name'] you can receive a web form and web data asynchronously over the post, namely $ _POST can only receive a document type Content-Type: application / data x-www-form-urlencoded submitted.

$ GLOBALS ['HTTP_RAW_POST_DATA'] receive data
If the data is not used over the post PHP can identify the type of document, such as text / xml or soap, etc., we can receive with $ GLOBALS ['HTTP_RAW_POST_DATA']. Populate the $ HTTP_RAW_POST_DATA containing the raw POST data. This variable is generated only when confronted with unrecognized MIME type of the data. $ HTTP_RAW_POST_DATA for enctype = "multipart / form-data" form data is not available. That use of $ HTTP_RAW_POST_DATA can not receive data over the web form post.

php: // input receive data
If a better way to access the raw POST data is php: // input. php: // input allows you to read raw POST data. It brings to memory and $ HTTP_RAW_POST_DATA less pressure than, and does not require any special php.ini settings and php: // input can not be used enctype = "multipart / form-data".
For example, the user uses a client application to post a document, the contents of the file server does not concern us, but we want to complete this file is saved on the server, we can use the following code:
$input = file_get_contents('php://input'); 
file_put_contents($original, $input); //$original is in server 


The above code uses file_get_contents ('php: // input') receiving post data, and then the data is written to $ original document, in fact, can be understood from the client to upload a file to the server, this type of application is very large, especially we will use PHP development to the C, C ++ and other application development jointly developed product, such as uploading pictures that combine flash use this principle to upload photos.
The following is a small example that illustrates $ _POST, $ GLOBALS ['HTTP_RAW_POST_DATA'] and php: // input in three different ways to receive POST data processing:
a.html
<form name="demo_form" action="post.php" method="post"> 
    <p><label>Name: </label><input type="text" class="input" name="name"></p> 
    <p><label>Address: </label><input type="text" class="input" name="address"></p> 
    <p><input type="submit" name="submit" class="btn" value="Submit"></p> 
</form> 

post.php
header("Content-type:text/html;charset=utf-8"); 
 
echo '$_POST receive:<br/>'; 
print_r($_POST); 
echo '<hr/>'; 
 
echo '$GLOBALS[\'HTTP_RAW_POST_DATA\']reveive:<br/>'; 
print_r($GLOBALS['HTTP_RAW_POST_DATA']); 
echo '<hr/>'; 
 
echo 'php://input receive:<br/>'; 
$data = file_get_contents('php://input'); 
print_r(urldecode($data)); 

Tags: PHP, post, data

Category: PHP Scripts

Dear visitor, you are browsing our website as Guest.
We strongly recommend you to register and login to view hidden contents.
<
  • 0 Comments
  • 0 Articles
8 October 2017 13:56

spincke324

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
good post, excelent info. thanks. porno gratis

<
  • 1 Comment
  • 0 Articles
26 January 2018 17:37

VirgilBlido

Reply
  • Group: Members
  • РRegistered date: 26.01.2018
  • Status: Currently Offline
 
Не знаю как вы, но я очень люблю смотреть кино онлайн и хочу представить вашему вниманию сайт http://filminov.ru/
В любое время суток стоит посмотреть

смотреть новые фильмы фэнтези бесплатно в хорошем качестве hd http://filminov.ru/films/fentezy/

Исторические фильмы cмотреть онлайн http://filminov.ru/films/istoria/

Смотреть лучшие криминальные фильмы онлайн http://filminov.ru/films/kriminal/

мультфильмы онлайн бесплатно http://filminov.ru/films/multik/

Лучшие приключенческие фильмы смотреть онлайн http://filminov.ru/films/prikluch/

Лучшие спортивные фильмы бесплатно в хорошем качестве http://filminov.ru/films/sports/

ужасы онлайн смотреть 2016-2017 новинки http://filminov.ru/films/ujas/

Лучшее кино:

http://filminov.ru/films/37488-smotret-korsikanec-onlayn.html

--------------------

<
  • 0 Comments
  • 0 Articles
5 March 2018 16:41

ra

Reply
  • Group: Guests
  • РRegistered date: --
  • Status:
 
The same is fake rolex watches based on black, paragraph table is more personalized. 40 mm diameter omega replica uk dial, 18K rose gold material pointer and time scale is rolex replica very conspicuous, the crown is also rose gold, black watch to replica watches uk bring a different color.

Information
Comment on the news site is possible only within (days) days from the date of publication.