[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

HTTP_RAW_POST_DATA

Posted on 2010-01-08
3
Medium Priority
?
533 Views
Last Modified: 2012-05-08
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?
0
Comment
Question by:3rdLifeWebDev
3 Comments
 
LVL 26

Expert Comment

by:jar3817
ID: 26213303
I would use $_POST if you can. Is there some specific reason you're using the RAW_DATA one?
0
 

Author Comment

by:3rdLifeWebDev
ID: 26213728
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
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 2000 total points
ID: 26219256
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

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses
Course of the Month20 days, 13 hours left to enroll

865 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question