$_POST empty on form submission
Posted: Sat Feb 26, 2011 5:50 pm
Hi,
I've been experiencing this strange issue with a couple of sites I've developed that whenever a form is submitted (any form on any of the sites) the $_POST variable appears to be empty. Which can be seen whenever I try to print it out. What appears to be happening is that the form is being submitted with a GET response rather than a POST, but I've definitely set the form method to POST (as shown) and this has only happened since my web host changed their server, and does not happen on my personal development box.
If I directly print out the results from the input with the following, I can see that the results are being sent but the $_POST variable is not being populated.
Another forum I found with my searching indicated the content type may be incorrect and suggested I tried the following, but this also didn't work.
I've currently found a way around it, but will not work for file uploads unsurprisingly. It's a pretty hacky way of fixing it and I was hoping someone may be able to shed some light on what might be the root cause so I can solve that rather than curing the symptom!
Cheers!
Tom
I've been experiencing this strange issue with a couple of sites I've developed that whenever a form is submitted (any form on any of the sites) the $_POST variable appears to be empty. Which can be seen whenever I try to print it out. What appears to be happening is that the form is being submitted with a GET response rather than a POST, but I've definitely set the form method to POST (as shown) and this has only happened since my web host changed their server, and does not happen on my personal development box.
Code: Select all
<form id="catgeory_new" method="post" action="categoryform.php"
onsubmit="return checkCategory('new');">
</form>Code: Select all
$data = file_get_contents('php://input');Code: Select all
if(empty($_SERVER['CONTENT_TYPE'])){
$type = "application/x-www-form-urlencoded";
$_SERVER['CONTENT_TYPE'] = $type;
}Code: Select all
parse_str(file_get_contents('php://input'), $_POST);Tom