LMSouq
general-dev Open

Create or write/append in text file

JE
Jerahmeel Acebuche
1 month ago
3 views
Problem Description
I have a website that every time a user logs in or logs out I save it to a text file. My code doesn't work in appending data or creating a text file if it does not exist.. Here is the sample code $myfile = fopen("logs.txt", "wr") or die("Unable to open file!"); $txt = "user id date"; fwrite($myfile, $txt); fclose($myfile); It seems it does not append to next line after I open it again. Also I think it would also have an error in a situation when 2 users login at the same time, would it affect opening the text file and saving it afterwards?

AI-Generated Solution

Powered by LMSouq AI · GPT-4.1-mini

✓ Solution Ready
Analyzing problem and generating solution…
Was this solution helpful?
Back to Knowledge Base