Try to google up "Websockets". It is a technic for realtime communication, so it is exactly what you need. It also has the advantage that you dont have to reload the site to get up to date with messages. I use it for all my chat applications.
There is no need for a database or files, because it takes all the messages you recive, and sends it to all other connectet clients without writeing it on the hard disk. Of course you CAN record it if you want.
If you dont want to read into this thema, try this website. It looks like it could help you
Oh, btw it is supported from a fu*****ing large part of modern webbrowsers, so you dont have to worry about that.