Here is my code:
<?
//**Catch variable values from Flash program**//
$filename = $_POST['filename'];
$day = $_POST['day'];
//**Open/Create current user access log and copy contents to string**//
$file = fopen($filename, "a+");
$currentLogStr = fread($file, filesize($filename));
fclose($file);
//**Check to see if log has entries
if ($currentLogStr != ""){
//**If log has entries make array out of data**//
$currentLog = explode(" ",$currentLogStr);
//**Check to see if current day is later than last entry date**//
if ($day > $currentLog[count($currentLog-1)]){
//**If current day later, add to log**//
$file = fopen($filename, "a+");
fwrite($file,$day . " ");
fclose($file);
}
}else{
//**If current day later, add to log**//
$file = fopen($filename, "a+");
fwrite($file,$day . " ");
fclose($file);
}
//**If current day not later than last entry do nothing**//
?>
My problem is this. the $filename = "something.txt" and it will save in the same directory as the script fine. However i want it to save in a sub directory called logs. This is the code I tried:
$file = fopen("/logs/$filename", "a+");
It wont save. Please help, as well as suggest improvements. Ive been doing php for 2 days ever since i joined this forum.
Thanks😕