In the results page/part of your script.
You have your form, then they click submit, then it has to go somewhere to be processed. I have always preferred doing this processing in the SAME php file like so..
<?php
if (!isset($_POST['submit'])) {
echo "<form action=\"$_SERVER['PHP_SELF']\" method=\"post\">";
?>
<!-- display HTML form here -->
<?php
} else {
// user submitted the form, process the data here and write it
// to a file
}
Also, you have the directory where files are being written to set to 777 (public-writable) right? PHP scripts do not run as You, they run with the same privileges as Apache (in otherwords, very little).