Saturday, March 5, 2011

how to make a chat server in php ?

Here you will get instructions on how to create and run a chat engine on your website, using a server-side programming language. This article assumes you have substantial technological knowledge.
1 Install a server-side language such as PHP or ASP if you need to.
2
Create a database table with fields to store a nickname, time and message.
3
Create a user interface with 2 text boxes - one for entering a chat message and other for displaying the chat log.
4
Create the client-side script using Javascript and AJAX techniques. The script should do the following things:
o Use AJAX to transfer chat messages one wishes to send to the server.
o Periodically check the server for new messages and add them to the chat window. It needs to send the time of the last message received.

5
Create the server-side script. It should do as follows:
o Add incoming messages to the database table with the nickname of the person that said it and the time stamp.
o Return new messages it has received after the time specified in the aforementioned AJAX request.
edit Tips
• Using an AJAX library might be helpful. A lot of AJAX libraries are available for download. One of these is AjaxLib
• Clear the database once the chat is over so that you can save on disk space used for the database.

No comments:

Post a Comment