I'm stuck with a problem fwrite() in PHP. I'm using Raspberry Pi with running server on it Apache2. This code works perfectly on Windows. The problem is that I cannot write anything to the file. The code just erase everything what is in file and didn't write to it. I can see that the file is updated, but still 0 bytes written. All permissions to file, folder and user is set as it should be. Even logging from the root account and executing PHP code will make any sense. I Googled for 3 days and someone has the same problem as me, they are mentioning something like SElinux. All help are appreciated.
This is my PHP code:
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
if (isset($_POST['temp']))
{
$name = $_POST['temp'];
$fp = fopen("/var/www/smarthome/webcompare6.txt", "a");
$data = "$name";
echo ("$name");
fwrite ($fp, ($data));
sleep (1);
fclose ($fp);
}
?>
This is my HTML form, from which I would like to write user input to .txt file:
<form name="form" method="post" action="room6.php">
Temperature: <input type="text" name="temp">
<input type="submit" name="set" value="Set">
</form></th>