Solved

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

Posted on 2010-09-14
6
906 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:ssuresh07
Comment Utility
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
Comment Utility
Hello, you can also take a look here
http://devzone.zend.com/article/1086
0
 
LVL 15

Expert Comment

by:Insoftservice
Comment Utility
I agree with @wmadrid1

http://www.phpopenchat.org/
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

744 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

21 Experts available now in Live!

Get 1:1 Help Now