number of ways, usually with activex which basically allows an application to run on the web. You can also combine PHP and javascript but to avoid refreshing the page everytime there is a new message, I would suggest using AJAX.
Basically online chat is not something newbies should attempt to build
