views:

230

answers:

7

Hello. Does anyone know how I can make a live chat on a webpage? Maybe using PHP and have the text stored into a database? If so, how could I get the text to automatically show on the users live chat, without refreshing?

Any ideas? Thanks.

A: 

There are dozens of existing solutions, basically you need some javascript which will update the chat after fetching updates from server.

Michal Čihař
A: 

Without refreshing... hmm... AJAX!

zaf
A: 

Use ajax to send and display messages. When a user sends a message, ajax goes to the server and store the message. To display messages, poll the server using ajax every few seconds to check for new messages. If new messages are found, display them.

Levi Hackwith
A: 

Flash or JavaScript&Ajax. It is not so complex.

topright
+1  A: 

See Free PHP-AJAX Chat applications:

http://www.ajaxlines.com/ajax/stuff/article/free_phpajax_chat_applications_.php

Sarfraz
+1  A: 

I'm guessing you're after something like Facebooks wonderful (ahem) Livechat system. I don't often suggest using an out of the box solution, but due to the fact there's a lot of stuff to think about if you want a reliable/stable chat system, I think it could be your best bet.

I've heard good things about AjaxIM, I've not developed with it but it looks well documented.

thebluefox
+2  A: 

While regularly polling the server works, it adds a lot of overhead. GMail, Facebook and the likes use Comet, which is a technique of keeping a HTTP request open for a long time so the server is able to push data to the client. This is assuming you want to do it without depending on a plugin.

If a plugin is no problem, you are better off with Flash, or a Java applet.

Cesar