Solved

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

Posted on 2010-09-14
6
907 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
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…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.

863 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now