Chatbox PHP script
Embed a chatbox into your web pages
Script zip: minichat2.zip (2kb)
Author: Paul Mutton
This PHP script allows you to embed a "chatbox" into your web pages, exactly like the one on the left of most pages on this site. You simply enter your nick name and a message, and it appears at the top of the list - simple!
- Totally rewritten from scratch.
- Much much more efficient than the previous version.
- HTML tags are filtered out.
- Imposes a max word size to avoid wrapping issues.
- Max nick and message lengths are enforced on the server side.
- Accidental "refresh" reposting is avoided.
- Appends all messages chronologically to the archive file.
- Displays latest 20 messages with the most recent at the top.
- Now logs I.P. addresses within comments (do what you want with them).
- Displays posting time in correct local time.
The zip file above contains a single PHP file called minichat2.inc.php. The only parts that you should really edit are the lines that looks like this:
$latest = $_SERVER['DOCUMENT_ROOT'] . "/temp/minichat2.latest";
$archive = $_SERVER['DOCUMENT_ROOT'] . "/temp/minichat2.archive";
minichat2.latest is just a text file where your chatbox messages will be stored, and will be created automatically. Once you've edited minichat2.inc.php, it's ready to run. Upload it to your website, and then make sure that the directory that minichat2.latest and minichat2.archive will be created in is CHMODed to 777.
To run the chatbox, you'll ideally need some php hosting; it won't work if php is not installed on the server.
Then, on the page where you want the chatbox to appear, use the following code:
Change the /path/to/minichat.inc.php to reflect the actual location of the file, and make sure that your file ends with .php and not .html. And then...that's it. You now have your very own chatbox :) Check the file - you can customise how many messages are displayed, and the time/date values, and pretty much everything, so it can blend in with your own site design. Simple, eh?
If you prefer a Windows environment, you can also host the script on a Windows hosting solution, as long as php is installed.
Some of these instructions were shamelessly stolen from Paul Haine, who has created a similar description for the chatbox that he runs on his web site.
Search this site
Copyright Paul Mutton 2001-2013