Hi guys, I am trying to add an instant messaging system to my website so that logged in member can chat one-on-one with other member on his/her contact list. I am aware that there are many of such free scripts that I can use but I would rather learn to do it myself. So, could anyone please tell me how to set it up or at least where the resources are.
It's not easily explained. I suggest digging through the code already made, and by way of AJAX use something like jquery. I won't give full code for time's sake, but here is a (rather clunky in the simple form, but with the right theme, etc. will be fine) breakdown on how to do this. Database Setup: Table for Users Contains: ID, User, Password fields Table for Conversations Contains: ID, From, To, Message, Time From here, you'll want to now pull this information from the database. If you have a list of users, have the logged in user click their name and have it bring them to a page where they can "see" the conversation. Really, this page is a "wrapper" so to speak. Create another page which actually grabs information from the database and displays it. Now on the "wrapper" page include it and refresh it (oh, every 5 seconds or so?) with JQuery or whatever AJAX wrapper you're using (it's much more efficient than reinventing the wheel). Make sure on the page that retrieves information, however, that the user is getting information WHERE To="SELECTED_USER" AND From="CURRENT_USER" and vice versa ordered by Time to get the conversation in order. Obviously to write, have a similar procedure where the submit button is a JQuery process submitting the data to the database. Regards, Dennis M.
google for wtag.. its very nice and simple ajax chat client... before a while I connected the chat with my site database.. if you know some php and mysql you can do it your self..