Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

$_POST is empty
 
JMarkMurphy
Jr. Member
 
Avatar
Total Posts:  22
Joined:  2008-10-28
Cincinnati, OH
 

I am trying to retrieve $_POST data from SAP.  I am running Zend Core on Ubuntu with the Zend Core installed Apache server.  The target application is Magento.  Not sure if that is part of the issue or not, but I don’t believe it is.  I have a SAP client that is trying to Post data to my website.  I have a simple echo server that I created with Zend framwork that has nothing more than an index controller that captures all the superglobal variables and writes them to a file.  I have a Magento server that contains the same capture code.  In both cases the capture code exists at the head of the index.php file before any dispatching has a chance to occur. 

Here is my capture code:

$file fopen('request.log''w');
fwrite($file'Raw Post: '.@file_get_contents('php://input')."\n");
fwrite($file'Request: '.print_r($_REQUEST,true)."\n");
fwrite($file'Get: '.print_r($_GET,true)."\n");
fwrite($file'Post: '.print_r($_POST,true)."\n");
fwrite($file'Cookie: '.print_r($_COOKIE,true)."\n");
fwrite($file'Server: '.print_r($_SERVER,true)."\n");
fwrite($file'Files: '.print_r($_FILES,true)."\n");
fwrite($file'Session: '.print_r($_SESSION,true)."\n");
fwrite($file'Environment: '.print_r($_ENV,true)."\n");
fwrite($file'Globals: '.print_r($_GLOBALS,true)."\n");
fclose($file);

I created a static HTML form that posts the same variables I expect from SAP.  I get all post data in the request.log for both the echo server and the Magento server (both are running on the same instance of Apache and Zend Core.

When my SAP client posts to the echo server all is well, and I capture all the data that is being sent.  When they post the same data to the Magento server, the post array is empty, and CONTENT_TYPE and CONTENT_LENGTH are missing from $_SERVER.  HTTP_REFERRER does indicate that the SAP client did arrive there.  As far as what the SAP client sees, all is normal up until they are ready to close out the session where the Post data from the login is required but missing.

Where should I look?  Does anyone have any ideas?

 
Magento Community Magento Community
Magento Community
Magento Community
 
PandaWebStudio
Member
 
Avatar
Total Posts:  40
Joined:  2008-04-19
Amsterdam, Netherlands
 

I also had this problem yesterday.
Magento Team added a hidden input field called form_key starting with 1.2.0 (I think):
<input name="form_key" type="hidden" value="’.Mage::getSingleton(’core/session’)->getFormKey().‘“ />
If the form_key value is not present in the post, the whole $_POST array is removed.

 
Magento Community Magento Community
Magento Community
Magento Community
 
JMarkMurphy
Jr. Member
 
Avatar
Total Posts:  22
Joined:  2008-10-28
Cincinnati, OH
 

I am running v1.1.8.  The thing that makes this odd is that a static form I created can post into Magento.

 
Magento Community Magento Community
Magento Community
Magento Community
 
JMarkMurphy
Jr. Member
 
Avatar
Total Posts:  22
Joined:  2008-10-28
Cincinnati, OH
 

Not a Magento issue.  The problem as it turns out is that the user typed the target URL without a slash at the end.  Apache redirected that to the same URL with a slash, and in the process converted it from a POST to a GET.  May be a config issue with Apache?  However if the user just sets their URL properly, then they get to the web site and the POST data gets sent as well.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top