So I have a form that users complete, and they are sent to a php page that sends all the variables via $_POST and then writes the output to a txt file. - that works just fine. My problem is I am trying to force the user to download it on that same page that creates the file, after the file is created and I can't seem to get it to work, nothing happens besides the file being created....
Here are the basics of what i have:
EDIT: Found the problem - I am getting a fatal error on the line with my fclose... any ideas what's wrong there?
$myfile="c-form" . date('m-d-Y_hia').'.txt';
$fileHandle = fopen($myfile, 'w');
//write stuff to file
$fclose($fileHandle);
//file is now closed
//now force user to download file that was just made
header('Content-disposition: attachment; filename=$myfile');
header('Content-type: text/plain');