I’m working through the book “PHP and MySQL Web Development” book to keep the mind sharp, I’m retired. The example is Bob’s auto parts where we have an order page that uses the post method to a processorder php page where it opens a file and writes each order on a separate line. The file is kept 2 directory levels back from the directory /var/www/html where the site files live. If there is an error opening or writing, there is a nice error message.
I could not get it to run so I did a chmod 777 on the orders and html directory’s and I know it’s a security no no but it runs now.
I get the error message just like it is supposed to when the file is not written. I can’t get the file to write.
I didn’t type in the code as it is provided on a cd.
Why is the file not being written?
What should the permissions on /orders/orders.txt and /var/www/html be?
Running a LAMP on raspberry Pi.
[php]@ $fp = fopen("$DOCUMENT_ROOT/…/orders/orders.txt", ‘ab’);
flock($fp, LOCK_EX);
if (!$fp) {
echo "<p><strong> Your order could not be processed at this time.
Please try again later.</strong></p></body></html>";
exit;
}[/php]
Thanks in advance