title: How to implement private chat in php using nodejs and socket.io
body: <p>I have implemented chat application using  this (<a href="https://github.com/jdutheil/nodePHP),but" rel="nofollow">https://github.com/jdutheil/nodePHP),but</a> now i want private chat between two users,but i don't know how to implement it.Please help me to solve the following issue.</p>
  
  <p>When a user logged into his account it will list(using hyperlinks with friends name) his friends like Facebook with a unique id associate with it,on clicking each item it opens new chat page with a text box and a button and start chat.Here is the code </p>
  
  <p><strong>start-chat-with-friends.php</strong></p>
  
  <pre><code>&lt;?php
    //uniqueid of the friend
    $id=$_GET['id'];
  ?&gt;
  &lt;form class="form-inline" id="messageForm"&gt;
                  &lt;input id="messageInput" type="text" class="input-xxlarge" placeHolder="Message" /&gt;
                  &lt;input type="submit" class="btn btn-primary" value="Send" /&gt;
              &lt;/form&gt;
  </code></pre>
  
  <p><strong>chatclient.js</strong></p>
  
  <pre><code>$( "#messageForm" ).submit( function() {
  var msg = $( "#messageInput" ).val();
  socket.emit('join', {message:msg} );
      $( "#messageInput" ).val('');
  });
  
  
  
  chatServer.js**
  
  socket.on('join', function( data ) {
  
  io.sockets.emit('new_msg'+data.to,{message:data.message});
      });
  </code></pre>