PHP page failing to receive POSTed form data

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.
LVL 35
Terry WoodsIT GuruAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

Terry WoodsConnect With a Mentor IT GuruAuthor Commented:
Update - here are some more details, and the solution. Perhaps this will be useful to others!

This forum post appears to describe the issue:

   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):

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

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).
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.
Terry WoodsIT GuruAuthor Commented:
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.
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

Jagadishwor DulalBraces MediaCommented:
Can you post your code?
psimationConnect With a Mentor Commented:
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.
Lukasz ChmielewskiConnect With a Mentor Commented:
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.
Terry WoodsIT GuruAuthor Commented:
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 "</pre>";
<form method="POST" action="">
<input type="submit" value="Save Changes">
<input type="hidden" name="blah" value="1">

Open in new window

Terry WoodsIT GuruAuthor Commented:
ps: There was a typo in the code above - </form should read </form>
Lukasz ChmielewskiConnect With a Mentor Commented:
Is the WebsiteA some kind of keyname ? Did you check for existence of that path in your php.ini ?
Terry WoodsIT GuruAuthor Commented:
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.
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".
Terry WoodsIT GuruAuthor Commented:
I found my own solution, but comments from others helped me get there - thanks!
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.