Solved

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

Posted on 2010-09-14
6
914 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
[X]
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
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
This article discusses how to create an extensible mechanism for linked drop downs.
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 create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

751 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