Hi All,
I am trying to write the results from a form that is also emailed and the email is working great, but I cannot get the text file to write.
Here is the code for writing the file to the server:
$date = date('H:i, jS F');
$outputtext = $message."\t".$Title."\t\t".$FirstName."\t\t".$LastName."\t\t".$YourTitlePosition."\t\t".$SubjectAreas."\t\t".$GradeLevel7th."\t\t".$GradeLevel8th."\t\t".$GradeLevel9th."\t\t".$Gradelevel10th."\t\t".$GradeLevel11th."\t\t".$GradeLevel12th."\t\t".$School."\t\t".$schooladdress1."\t\t".$schooladdress2."\t\t".$City."\t\t".$State."\t\t".$Zip."\t\t".$emailaddress."\t\t".$Washington."\t\t".$AmericaOne."\t\t".$greed."\t\t".$scaring."\t\t".$freeloaders."\t\t".$wouldlikebecause."\t\t".$planonusing."\t\t".$averagestudents."\t\t".$videouse."\t\t".$PromisetoprovideMaterialUse."\t\t".$comments."\n";
$write_file = "../../_private/don.txt";
$fp = fopen($write_file, 'a') or die("Couldn't open ".$write_file);
if (!$fp)
{
echo '<p><strong> Your comments could not be saved to the server at this time.</strong></p>';
echo '<p><strong> Please try again later.</strong></p></body></html>';
exit;
}
fwrite($fp, $date.'--'.$outputtext, strlen($date.'--'.$outputtext));
fclose($fp);
echo '<p>Comments submitted on ';
echo $date;
echo '</p>';
echo '<p>Information saved to server.</p>';
I get this message:
Warning: fopen(../../private/don.txt): failed to open stream: Permission denied in /home/inthecla/public_html/stossel/forms/index.php on line 116
Couldn't open ../../private//don.txt
There is currently a directory off of the root called "_private" that the FrontPage files are written to and I did change the read write permission to 666 if that is needed, I do not know.
Anyone have any ideas?
I can get this to write IF I put it in the same directory as the index.php file. I would prefer not to since I have 50 forms and 50 text files. I would like to have this file in a directory like "results/az.txt"
Thanks in advance,
Don