HTTP_RAW_POST_DATA

My shopping cart is silent posting using HTTP_RAW_POST_DATA.

I am trying to insert variables with $var=urlencode($_POST['var']);

I have been reading about problems where $_POST does not grab variable posted with HTTP_RAW_POST_DATA.

Is $_POST the correct protocol?
3rdLifeWebDevAsked:
Who is Participating?
 
Ray PaseurConnect With a Mentor Commented:
Here is how I retrieve a silent "raw" post of XML.  This segment is untested, but it was ripped out of a production script so it should be OK.  best regards, ~Ray
<?php 

// GET RAW POST DATA FROM STDIN
$postdata = '';
$postdata = trim(@file_get_contents('php://input'));

// NECESSARY ONLY FOR OUR TEST DATA
$postdata = urldecode($postdata);

// IF THE DATA IS PRESENT, MAKE AN OBJECT
$xml = stripslashes($postdata); // IF MAGIC QUOTES IS _ON_
$xml = str_replace("\r\n", PHP_EOL, $xml);
$obj = @SimpleXML_Load_String($xml); // SUPPRESS ERROR MESSAGE ELSE CANNOT SEND HEADER

// IF THE OBJECT IS INVALID
if (!$obj) http_error('400', ' THE POSTED DATA CANNOT BE INTERPRETED AS XML');

// REMOVE AN UNWANTED THING FROM THE XML
unset($obj->Messages);
$saved_xml   = $obj->asXML();

// ETC ETC

Open in new window

0
 
jar3817Commented:
I would use $_POST if you can. Is there some specific reason you're using the RAW_DATA one?
0
 
3rdLifeWebDevAuthor Commented:
I should have been more clear... I do not control the shopping cart or the code behind it.

I am building the mechanism to receive the silent post.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.