Jump to content

Recommended Posts

I have a chat box coded in PHP on my website that has to be refreshed each time someone enters a message. I am wondering if there is a way to make it where the chatbox.php page automatically displays new entries to the database without having to refresh the page. So, if I am on the chat box and someone enters a message, I don't want to have to refresh the chat box in order to see the new message. I want the chat box to show the newly-entered message on the chat box page without having to refresh the page.

 

So, how can I do this? In case anyone needs the URL to my website with the chat box on it, here it is: http://generalgamingplanet.com/chat . Please tell me everything you can to help me.

Well, I want it to be like a real time chatbox, but that's OK. I changed my mind though and I want something different now: I want it to be where it refreshes each time a message is posted by someone. So, if someone other than me posts a message, I want the chatbox to refresh for everyone who is viewing it. That way, everyone gets to see the updated chat log at the same time. You know what I mean? So, I guess my new question is this: Is there any way to refresh a page once a new entry is added to the database?

There is no exact 'realtime' method using code.  You can have it request data from the server every x seconds, but it would never be true real time, also it would put a strain on the server if you have many people doing this.

 

For real time options, you might try flash since I think it creates a socket connection for its chat based apps.

There are some decent AJAX based chat programs out there (like this one: https://blueimp.net/ajax/#demo), so it can be done.

 

As for how to do it, well that's beyond the scope of this thread. The first thing would be to learn the basics of how ajax works (google is your friend), and then ask some specific questions from there.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.