Demo
Please load the following links in different browsers otherwise it wont work:
Sample Chat User Swadesh
Sample Chat User Vimla
Sample Chat User Brijesh
Introduction
This jQuery chat module enables you to integrate Gmail/Facebook style chat into your existing website.
Features
1. Gmail style bottom right display of chat boxes
2. Keeps chat boxes open and stores state (data) even when pages are browsed/refreshed similar to Facebook
3. Displays “Sent at…” after 3 minutes of inactivity
4. Displays “X says…” & blinks chat boxes when window is not in focus
5. Minimize and close chat boxes
6. Auto-scrolling of chat text
7. Auto-back-off polling policy (hits the server less-often when chat activity is low)
8. Extremely simple to integrate into existing site
Getting Started
You must first create a mySQL table as below (or import db.txt provided in project files)
CREATE TABLE IF NOT EXISTS `chat` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `from` varchar(255) NOT NULL DEFAULT '', `to` varchar(255) NOT NULL DEFAULT '', `message` text NOT NULL, `sent` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `recd` int(10) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=539 ; CREATE TABLE IF NOT EXISTS `users` ( `uid` int(11) NOT NULL AUTO_INCREMENT, `username` varchar(30) DEFAULT NULL, `password` varchar(30) DEFAULT NULL, `email` varchar(100) DEFAULT NULL, `gender` varchar(8) NOT NULL, `dob` varchar(16) NOT NULL, `phone` varchar(20) NOT NULL, `profile_image` varchar(50) NOT NULL, PRIMARY KEY (`uid`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=21 ; -- -- Dumping data for table `users` -- INSERT INTO `users` (`uid`, `username`, `password`, `email`, `gender`, `dob`, `phone`, `profile_image`) VALUES (1, 'Swadesh', 'pass1', 'itswadesh@gmail.com', '', '', '', ''), (2, 'Brijesh', 'pass1', 'brijesh@gmail.com', '', '', '', ''), (3, 'Vimla', 'pass1', 'vimla@gmail.com', '', '', '', '');
Add the following scripts to your page template
<code><script type="text/javascript" src="js/jquery.min.js"></script> <script type="text/javascript" src="js/chat.js"></script> </code>
Add the following CSS to your page
<link type="text/css" rel="stylesheet" media="all" href="css/chat.css" /> <link type="text/css" rel="stylesheet" media="all" href="css/screen.css" /><!--[if lte IE 7]> <link type="text/css" rel="stylesheet" media="all" href="css/screen_ie.css" /> <![endif]-->
Edit chat.php and set your database parameters and try your website.
For better understanding, load 3 different browsers (internet explorer, firefox, safari) and point them to samplea.php, sampleb.php and samplec.php.
Click on “chat with Vimla” link and watch the chat functionality come alive!
Inorder to integrate your existing website, you must place all your content between the “main_container” div tag.
Browser Compatibility
1. Firefox 2+
2. Internet Explorer 6+
3. Safari 2+
4. Opera 9+
What?s Taking place i’m new to this, I stumbled upon this I’ve found It positively helpful and it has helped me out loads. I’m hoping to give a contribution & aid different customers like its aided me. Good job.
Thanks a heap for this post, glad to see there are still some excellent writers around the web!
Interesting… Thanks for this post!
how do i create a login and sign up for this chat box?
hi– i was working on the chat and i am not sure if this is a mistake:
in the demo files at the top:
$_SESSION[‘chatuser’] = ‘1’;
$_SESSION[‘chatuser_name’] = ‘Swadesh’;
shouldnt $_SESSION[‘chatuser_name’] be $_SESSION[‘chatname’] ??? or chatusername??
hi
Your char script very very nice. you took efforts very good
it is anant garg’s script
Yes its anant garg’s script. I just modified it so that it will be practically usable for a developer
very good thankks but not work in google chrome
Is there any asp.net version
I looking for an asp.net version. Is there any asp.net version?
Thanks bro………its very helpful for me to create my own php chat on mah website………thanks a lot………….
Thanks for updating this chat script.
how to change me into username??? Thanks
I need download the script!
It is not working in IE7 for me.
I could not test it in ie7 but its working fine with ie8 for me.
It also works well with Mozilla Firefox and Google Chrome
this chat script depends both on uid and username field. Where uid is a integer field with auto increment and username is just a varchar field
hello sir
in this script we insert user name and password using login form . it is possible in this script if it is possible.
pls send me solution on my email id
pratapm8@gmail.com
Integrate with your current running log in application and declare at log in both variables. Just go to YouTube and watch Alex’s new registration video.
please add ability to group chat boxes !
Can’t be that easily … trying it …
pop up box is not opening please help
Nice script.. But bro, tell me how to show “user is offline” ??? when we will start chat someone but if he is not online then how to show in chat/message “he/username is not online” ????
Plz tell me.. thanks advance..
5/5
Dear Abi,
Please find the following link answering your exact question.
http://www.2lessons.info/2012/01/how-to-track-online-status-of-user-in.html
Itz good, but i meant how to show in chatbox when we type message or enter message like facebook chat??? Will u update ur chat script ???? Becoz I’m still newbie, i cant modify ur chat script..
Thanks
Your blog is sooooo awesome so meri request hai aap se plz :p update this script… Like This http://www.ajaxkhan.com/?p=7
Ma forse sono l’unico a cui non funziona? Credo di avere dei problemi…oppure non è possibile parlare da soli?
Is it possible speack alone for a trial? becouse i have not my answers!
Is there a way to put in blogger?
Hearty thanks for Swadesh.. I already know about Anant’s script.. but i can’t still implement that script for working on my site. Now you simplified the process thanks…
can this work only on asp.net or jsp instead of php??????
Also can u please tell me y i can’t run 2 instances of the chat @ d same time on chrome????
Sir i am fan of ur coding style and this code i have converted into struts2 and it works like charm.
But my problem is when i go to some other page like(My friends profile etc..)
this chat window do not appear how to do that please help me out sir
Thanks Darshana,
May be you could save the whole chat script into a page and include it into every pages you want it to appear.
This script is working well. thank you.., i like to have some more chat features in this script. Can any tell how to include smileys or emotions to this script?
Thanks… You script is very good and clean
it cant help a lot because it doesnt support jabber Xmpp protocol ..using database …is like a fake chat
Hello as we can make it play a sound every time you send the message to the destination, I have seen a website that when you click on the button below to unlock a window appears sound, change name, this is the website: http: / / zopim.com /, will be attentive to your answer.
Hi,
nice article, is there any .NET version of this code is available?
appreciate your response.
Thanks.
Hi ,
I need same jquery chat plugin for asp.net .this one is php .please any one help me
how to show the default history when start chat with some one. Please help.
hello swadesh…. i m bhumika shukla…. ur script is really very nice but i have some problems related to this script whn i try chat with a person its not working properly, every user getting same message on every page.
Just watch Alex’s Video by PHPAcademy New Register Login Series you should find your answers.
Hello sir I’m integrate your chat although i have already set it before 4 months in these time it
it is working but with some problem problem is thaat when we chat any user who is online
message displays continiue in recurisive order in my own chatbox but not in user chat box in
chat table in from table sender id is storing in integer that is correct but in to field only user from whom i’m chating user name is stroing in plcace of that id which is in integer.I want to lance my site soon I’m in trouble and i also submit this site as project in my MCA i’m in last same plz solve problem via e-mail thanks in advance my email-shyambca123@gmail.com
can you sir add comment in important php script in chat.php file
Sir your chat box not working in online but it is working in offline may u help me why
how can it run on live server
if more window open in one browser it goes left side and we can’t able to see that
so is that possible to open only 5 or 6 window if next window will open it close old one.
you r super swadesh.
I have some problem in chat,if user enter text in text area and press enter twice. message is not displayed in chat box window but chat is sent to other user.
In my local host this script run very nice.i have no problem.
So any kind of suggestion so please give…..
Thanks
Hey thanx man.. really cool plugin and very helpful for me..
most of the work is done by you all I need to do is change the styling a bit and use my user database with my own session management…
thanx again..
hi i want to display online symbole like we will get in gtalk if user online any suggestions please code?
I’m trying to make it work with new jquery version 1.9.1. get error. also trying to include sizzle.
what’s wrong..? any special compiled jquery required? any module missing..?
It is in reality a nice and useful piece of information.
I’m happy that you simply shared this helpful info with us. Please keep us informed like this. Thank you for sharing.
Its nice, however _VERY_ restrictive. Since it is already using MySQL for the chats, no reason not to use MySQL for the $_SESSION[‘username’].
Perhaps the author will update for this, if not it is rather useless for most serious sites that would be interested in using, or even purchasing, it.
Hello script is good ineed to integrate complete site i mean when i go through another link in same site then chat window is not showing so i need chat window in complete site. can you help me regarding this
Hello guys if you need chat code am selling where users online and offline status if you are intrested mail me
thank you so much……this code is working superbly
Hi, everything gets added to the DB and the message sends but the other person can’t receive it? What am i doing wrong?
thankss
Problem running with chat demo in my php site.
Change chat.php with my database credential, created chat and user table.
When running sample a and b program, messages sent by sender not appearing to chat box of receiver.
really nice work
how to make the index page when a user loged in ??
every time i shoud wite like sample . or what is the solution
Thanks 🙂
I have some problem in chat,if user enter text in text area and press enter twice. message is not displayed in chat box window but chat is sent to other user.
In my local host this script run very nice.i have no problem.
So any kind of suggestion so please give…..
Thanks
can anybody convert this to mssql?
Hi Im trying to implement this using MSSQL can anyone please give me some advise?
how to add usertyping
This to me has been a foundation code to work with… Its not restrictive, it just needs to be expanded and a few bugs fixed but its a GREAT FOUNDATION WORKING CODE.
The sessions keeps record of the user’s current history but all records are stored in the database.
From here i was able to expand and pull back out old records, hyperlink names, change styles, include avatars, allow file transfer, restrict open chatboxes to space available else minimise and include notification sounds etc…. The only thing left for me to do is keep track of open and minimised chats when the user logs out and it wont be that hard, just simply to store that in a session and upload on logout or during chat.
I want to change show name to image , can you help me ?
Thanks for the Code, I have used this chat in my website which is built in CI Mysql, I found two problems, one is the username is accepting the space between names for eg. Arun kumar. Second one how to remove the ID which comes along with username.
wow Swadesh!! you are such genius. With just a litle modification i make it to work dynamically based on online users name in my online table, and it works perfectly as i like it. But when i was trying to make it appear on all my pages its crippled my compidence, such as my main css is distout. Any hint on how to put it? Thanks 4 share such helpful idea.
Hello , I want to change show name chat yo image chat . Please help me in file chat.php .
tyt
yt
ytr
y
y
tru
besttechlab :
Thanks buddy. It’s a nice post.
I am getting stuck somewhere because of session.
What?s Taking place i’m new to this, I stumbled upon this I’ve found It positively helpful and it has helped me out loads. I’m hoping to give a contribution & aid different customers like its aided me. Good job.
Hi i have a problem.The chat can’t instert the data message on database.
Demo here http://www.bestdialog.com/chat/samplea.php
I realize this is free and I appreciate you sharing your work – very respectable, however I want to make some suggestions as I am ripping it apart for my own use. Under startChatSession there is a part in the iteration of the session data that makes an ajax request for the username each and every time, not only is this a database hit every time this is done it also keeps the page from loading fast because the page is waiting on the scripts that are NOT asynchronous to perform asynchronous requests. So if you have a site that has heavy user chat you could have as many requests as you do lines of chat stored in the session when you refresh a page. This can start to become 80+ to 200+ requests in which the chat boxes will not show up until the scripts are done initializing. These requests aren’t even necessary because the session data actually looks up the username of the sending user, no need to do it 200+ times. I will post my other suggestions as I walk through them to share with others, but by commenting out the sub ajax requests that are unecessary I’ve been able to dramatically decrease page load times.
under
startChatSession()
// $.ajax({
// url: “ajax.php?M=Chat&action=chatname&usw=”+item.f,
// cache: false,
// dataType: “json”,
// async: false,
// success: function(data) { chatusername=data.unm; } });
chatusername = item.u;
Thanks buddy. It’s a nice post.
I am getting stuck somewhere because of session.
Nice work with the username problem of anant garg’s chat 😀 cheers
Your chat script is awesome and wonderful. I like it very much.. Is there a way to have a desktop notifications when we are in another browser?
Thank you.
There is a similar chat app: http://matteo.awiki.org/matteoProject/wiki/portingWikiChat