I used to be able to post variables to pure PHP pages, but it seems to have been broken by a server setting change with our web host, because this used to work just fine. Basically, I've set up a form to retrieve and allow the user to download a file from a secure location outside of the public folder on the server (only to authorized users). It works like this:
request_file.php
<?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Request File</title>
</head>
<body>
<form name="request_file" method="post" action="retrieve_file.php" enctype="multipart/form-data">
<input type="text" name="filename" />
<input type="submit" value="Submit" />
</form>
</body>
</html>
retrieve_file.php
<?php
session_start();
header("Vary: User-Agent");
header("Pragma: public");
header("Content-type: text/plain");
header("Content-Disposition: attachment; filename=".$_POST['filename']);
readfile( "../../".$_SESSION['userid']."/".$_POST['filename'] );
?>
However, if I replace the retrieve_file.php code with simply this:
<?php
echo "<pre>";
var_dump( $_POST );
echo "</pre>";
?>
It will print out an empty array, every time. However, if I put HTML headers on retrieve_file.php, it works just fine. However, for exporting a file, this won't really work since the headers have to be sent out AFTER the page gets its post variables.
Any ideas how to work around this? Please don't berate me for pulling files this way, it actually works well for our very specific application.
Thanks!
Additional Information
PHP Version: 5.4