This particular design of web-based chat uses variables posted from a form, processes them into HTML and writes them to a file. http://www.phpbuilder.com/columns/mhall20000621.php3
This article will show you how to create a quick-n-easy chat script using PHP and a very simple MySQL database. http://www.devarticles.com/c/a/MySQL/A-MySQL-Driven-Chat-Script/
This tutorial will show you how to create an AJAX chat system using JSON as the data exchange format rather that the standard HTML. http://www.dynamicajax.com/fr/JSON_AJAX_Web_Chat-271_290_324.html
A simple chatbox written in PHP and MYSQL database, includes table setup and basic administration area. http://www.chipmunk-scripts.com/board/index.php?forumID=43&ID=9908