# Getting POST Data in Request

**URL:** https://forum.kirupa.com/t/getting-post-data-in-request/185759
**Category:** programming
**Created:** [April 16, 2006, 6:15am UTC](https://forum.kirupa.com/t/getting-post-data-in-request/185759 "2006-04-16T06:15:35Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Jeff\_Wheeler](https://avatars.discourse-cdn.com/v4/letter/j/59ef9b/32.png) [@Jeff\_Wheeler](https://forum.kirupa.com/u/Jeff_Wheeler)
#### Post date: [April 16, 2006, 6:15am UTC](https://forum.kirupa.com/t/getting-post-data-in-request/185759/1 "2006-04-16T06:15:35Z")

</div>

Hi,

I’ve been trying to read in an xml value of a post request… it’s kinda hard to explain, so here’s a little excerpt of what the HTTP POST request I’ll be sending to the PHP page will look like (obviously there is really more…):

> [@HTTP Request Header](#):
>
> POST /code/java-socket/request.php HTTP/1.1  
> HOST: [nokrev.com](http://nokrev.com)  
> User-Agent: Java/1.5.0\_06  
> Content-type: text/xml  
> Content-Length: 61
> 
> \<?xml version=‘1.0’ encoding=‘UTF-8’?\>\<content\>test\</content\>

How do I access the last xml part in PHP? It is a valid HTTP request as far as I know, but PHP doesn’t seem to allow you to get it. It only allows access to that if you have something equaling it…

Thanks 🙂

---

<div class="post-metadata">

### Author: ![955](https://avatars.discourse-cdn.com/v4/letter/9/4bbf92/32.png) [@955](https://forum.kirupa.com/u/955)
#### Post date: [April 16, 2006, 10:18am UTC](https://forum.kirupa.com/t/getting-post-data-in-request/185759/2 "2006-04-16T10:18:01Z")

</div>

$HTTP\_POST\_DATA?

EDIT: It’s actually $HTTP\_RAW\_POST\_DATA, not $HTTP\_POST\_DATA 😉

---

<div class="post-metadata">

### Author: ![fluid\_tw0](https://avatars.discourse-cdn.com/v4/letter/f/48db29/32.png) [@fluid\_tw0](https://forum.kirupa.com/u/fluid_tw0)
#### Post date: [April 16, 2006, 2:34pm UTC](https://forum.kirupa.com/t/getting-post-data-in-request/185759/3 "2006-04-16T14:34:11Z")

</div>

$\_POST

---

<div class="post-metadata">

### Author: ![Jeff\_Wheeler](https://avatars.discourse-cdn.com/v4/letter/j/59ef9b/32.png) [@Jeff\_Wheeler](https://forum.kirupa.com/u/Jeff_Wheeler)
#### Post date: [April 16, 2006, 3:37pm UTC](https://forum.kirupa.com/t/getting-post-data-in-request/185759/4 "2006-04-16T15:37:26Z")

</div>

fluid\_tw0: It’s not $\_POST, because that only contains key-value pairs. If you simply pass it data, it won’t go into that array.

Nick: Works beautifully. Thank you. 🙂

---

<div class="post-metadata">

### Author: ![Jeff\_Wheeler](https://avatars.discourse-cdn.com/v4/letter/j/59ef9b/32.png) [@Jeff\_Wheeler](https://forum.kirupa.com/u/Jeff_Wheeler)
#### Post date: [April 16, 2006, 7:03pm UTC](https://forum.kirupa.com/t/getting-post-data-in-request/185759/5 "2006-04-16T19:03:02Z")

</div>

fluid\_tw0: It’s not $\_POST, because that only contains key-value pairs. If you simply pass it data, it won’t go into that array.

Nick: Works beautifully. Thank you. 🙂

**Edit** : Here’s the nice pretty code that I used:

```php
<?php
$inputSocket = fopen('php://input','rb');
$contents = stream_get_contents($inputSocket);
fclose($inputSocket);

echo $contents;
?> 

```

More info here:  
[http://ee.php.net/manual/en/wrappers.php.php](http://ee.php.net/manual/en/wrappers.php.php)

[whisper]I’m surprised nobody ever uses these things… it’d be great for ajax.[/whisper]

---

<div class="post-metadata">

### Author: ![fluid\_tw0](https://avatars.discourse-cdn.com/v4/letter/f/48db29/32.png) [@fluid\_tw0](https://forum.kirupa.com/u/fluid_tw0)
#### Post date: [April 16, 2006, 8:16pm UTC](https://forum.kirupa.com/t/getting-post-data-in-request/185759/6 "2006-04-16T20:16:28Z")

</div>

now i see it 😃
