Solved

PHP page failing to receive POSTed form data

Posted on 2011-03-15
13
241 Views
Last Modified: 2013-10-06
I have a website where all of a sudden submitting a form via POST returns no data in $_POST

I can't understand why $_POST is empty, as even a phpinfo() shows the _SERVER["REQUEST_METHOD"] is POST

Providing code for this isn't trivial as there are several files of supporting functions etc being used, and I have been changing some code in those prior to the problem but I don't know why it would make a difference. I'm really hoping someone's seen this before, and can provide a quick fix!

Using Apache on Debian Linux (a fairly old version), PHP version is 5.2.9.
0
Comment
Question by:Terry Woods
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 2
  • 2
  • +2
13 Comments
 
LVL 17

Expert Comment

by:psimation
ID: 35144298
Well, start with the basics.

1. Make sure the form still has "method="POST" " in it's attributes.
2. The values are stored in $_POST[], not $_POST.
0
 
LVL 35

Author Comment

by:Terry Woods
ID: 35144342
Forms on more than one page that I haven't changed recently have stopped working too. I have been playing with code utilised by all pages affecting sessions, and have reviewed it but can't see anything that would seem to make a difference.

A print_r($_POST) run by the very first line of PHP code returns an empty array.
0
 
LVL 15

Expert Comment

by:Jagadishwor Dulal
ID: 35144419
Can you post your code?
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 17

Assisted Solution

by:psimation
psimation earned 200 total points
ID: 35144632
Another quick test to ensure that it's not something "globally" broken is to just create a very quick 1 field form on the same domain and making sure that it still works.
0
 
LVL 27

Assisted Solution

by:Lukasz Chmielewski
Lukasz Chmielewski earned 300 total points
ID: 35145001
Did you try different browsers ?
I'd go with psimation's suggestion, create one simple form and check it there, this way we can rule out the environmental cause. If it works - then it's your code.
0
 
LVL 35

Author Comment

by:Terry Woods
ID: 35174053
Ok, after trying all sorts of simplifications, I've found the behaviour described below. Let's assume my website sits in a folder called web_root/WebsiteA, web_root being the Apache web root.
- putting a test script (below) in my website folder web_root/WebsiteA shows $_POST to be empty in IE7, but populated for FireFox
- putting the test script into any other folder (the parent folder of my website (web_root), or a sibling level [ie a different website] folder eg web_root/WebsiteB) shows $_POST to be populated when submitted
- changing the website's folder from "WebsiteA" to "WebsiteB" fixes the problem - submitting the form shows $_POST to be populated

Does this point towards there being a problem with Apache on that particular folder name?
<?
print "POST:<pre>";
print_r($_POST);
print "</pre>";
?>
<form method="POST" action="">
<input type="submit" value="Save Changes">
<input type="hidden" name="blah" value="1">
</form

Open in new window

0
 
LVL 35

Author Comment

by:Terry Woods
ID: 35174056
ps: There was a typo in the code above - </form should read </form>
0
 
LVL 27

Assisted Solution

by:Lukasz Chmielewski
Lukasz Chmielewski earned 300 total points
ID: 35174678
Is the WebsiteA some kind of keyname ? Did you check for existence of that path in your php.ini ?
0
 
LVL 35

Author Comment

by:Terry Woods
ID: 35176772
The actual name is C1060 - it's not mentioned in the php.ini file, or any Apache conf files as far as I can see.
0
 
LVL 58

Expert Comment

by:Gary
ID: 39551279
I've requested that this question be deleted for the following reason:

The question has either no comments or not enough useful information to be called an "answer".
0
 
LVL 35

Accepted Solution

by:
Terry Woods earned 0 total points
ID: 39551280
Update - here are some more details, and the solution. Perhaps this will be useful to others!

This forum post appears to describe the issue: http://lists.rubyonrails.org/pipermail/rails/2006-March/027283.html

   You cannot post any data to mixed NTLM and non-NTLM authenticated Web sites. Microsoft Internet Explorer requires NTLM authentication for all visits to a website after you visit one NTLM authenticated folder of the website.
I can confirm this behaviour as follows:

When I visit http://mydomain/websiteA/index.php then http://mydomain/websiteA/POST_test.php $_POST is not populated by submitting the test page.

However, closing all my IE7 windows then browsing straight to http://mydomain/websiteA/POST_test.php shows $_POST IS populated by submitting the test page.

And one of the suggested solutions from the above linked forum post appears to be:

   
The only way I have seen to get IE to "forget" it has previously NTLM-authenticated to a site is to send a 401 page status. This effectively resets the IE authentication state.

It turned out that the problem was caused by a previous request to an unrelated page which made use of NTLM authentication like this (or similar):

<?php
  if (!isset($headers['Authorization'])){
    header('HTTP/1.1 401 Unauthorized');
    header('WWW-Authenticate: NTLM');
    exit;
  }
?>

Open in new window


After that authentication was done, all $_POST data was received empty until IE was closed and re-opened. I worked around the issue by removing the above code and instead arranging for Apache to use NTLM within our Intranet (which sets the $_SERVER['REMOTE_USER'] variable). (Outside of our intranet, Apache authentication is still used).
0
 
LVL 35

Author Closing Comment

by:Terry Woods
ID: 39551282
I found my own solution, but comments from others helped me get there - thanks!
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

749 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