Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How to create a chat in php? or How to push message from server to client?

Posted on 2010-09-14
6
911 Views
Last Modified: 2013-12-12
Hi,

I'm about to include a chat feature in my website. This chat should not be like in any other website, as providing a link like "Click here to chat". And I dont want to include any opensource chat feature.

This will contain a embedded Text Box in the webpage, where the user will directly enter the message and click submit, which will reach the administrator and the administrator will reply the user individually. This is because of, I need to validate some points while the user enters any message.

If my above statement was not clear, then my question is
How to push message from the server to the client?
0
Comment
Question by:ssuresh07
6 Comments
 
LVL 7

Expert Comment

by:tlovie
ID: 33679016
I don't think you can "push messages from the server to the client"  but you can create this behavior by writing some javascript to poll the server frequently, say once every 2 seconds to see if the server wants to say something to the client.
0
 
LVL 5

Accepted Solution

by:
wmadrid1 earned 250 total points
ID: 33680192
Hi ssuresh07,

That is possible. "pus messages from the server to the client".
You can do it using sockets in PHP.
The basic idea is to make a sockets connection with each client and receive and send messages from each client.
The thing is how receive the messages in the client.

The easy way is do it with flash, here is a inetresting guide of how easily make a little chat:
http://www.kirupa.com/developer/flash8/php5sockets_flash8.htm

Other way is make the client connection with Javascript
0
 
LVL 7

Expert Comment

by:Vimal DM
ID: 33684507
Hai,

Just look at the following link

http://github.com/pubnub/pubnub-api/tree/master/php/


1) Where you need to download that source code and see the functionality that it developed

2) And update the "'YOUR-PUBLISH-KEY', 'YOUR-SUBSCRIBE-KEY'"

Thanks.
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:ssuresh07
ID: 33692731
Hi wmadrid1 and vimalmaria,

your comments are looking useful, I'm checking the coding, because I'm new to this socket concept.

please post if there are any other easy way or any learning materials to understand sockets.

Thanks
0
 
LVL 27

Expert Comment

by:Lukasz Chmielewski
ID: 34738153
Hello, you can also take a look here
http://devzone.zend.com/article/1086
0
 
LVL 15

Expert Comment

by:Insoftservice
ID: 35704807
I agree with @wmadrid1

http://www.phpopenchat.org/
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question