Olá,   Eu encontrei um sistema de chat muito bom!   esta servindo muito para mim!  pois bem, quando um usuario acessa o chat, aparece uma mensagem "Usuario: Entrou na Sala as 00:00:00 PM/AM" eu gostaria que quando o usuario sai-se do chat aparece-se uma mensagem "Usuario: Saiu na Sala as 00:00:00 PM/AM"  o script é esse:   <? if (empty($action))   ShowLoginForm(); elseif ($action == "posts")   ShowAddPosts(); elseif ($action == "users")   showusers(); elseif ($action == "form")   GetInput(); elseif ($action == "logo")   showlogo(); elseif ($action == "enter")   Login();  function ShowLoginForm() { $time = date ("h:i:s A");    ?> <html> <head> <title>Clan World Stars - .:: CHAT ::.</title> </head> <link href="http://www.trafegogratis.novacontagem.com/_style/style_button.css" rel="stylesheet" type="text/css"> <style type="text/css"> body{  	background: #FFF; 	color: #222; 	font-family: Verdana, Tahoma, Arial, Trebuchet MS, Sans-Serif, Georgia, Courier, Times New Roman, Serif; 	font-size: 11px; 	line-height: 135%; 	margin: 0px; 	padding: 0px;  	text-align: center;  } #redirectwrap{ 	background: #F0F5FA; 	border: 1px solid #C2CFDF; 	margin: 200px auto 0 auto; 	text-align: left; 	width: 270px; }  #redirectwrap h4{ 	background: #D0DDEA; 	border-bottom: 1px solid #C2CFDF; 	color: #3A4F6C; 	font-size: 14px; 	margin: 0; 	padding: 5px; }  #redirectwrap p{ 	margin: 0; 	padding: 5px; }  #redirectwrap p.redirectfoot{ 	background: #E3EBF4; 	border-top: 1px solid #C2CFDF; 	text-align: center; } </style> 	</head>                  <script language="JavaScript">                      function valida() {                            if (document.chat.nick.value=='') {                                  alert('Você deve informar seu Nick!');                               document.chat.nick.focus();                                  return false                            }                            if (document.chat.nick.value.length < 3 ) {                                  alert('O nick deve ter no Minimo 3 caracteres!');                               document.chat.nick.focus();                                  return false                            }                            if (document.chat.nick.value.length > 20 ) {                                  alert('O nick deve ter no Maximo 20 caracteres!');                               document.busca1.busca.focus();                                  return false                            }                            }                                          document.chat.nick.focus();                  </script>                      <form onsubmit="return valida()" name="chat" method="post" action="index.php" target="_top"> 	<body> 		<div id="redirectwrap"> 			<h4>Chat - World Stars</h4> 			<p><center>Nick: <input type="text" name="nick" size="8" MAXLENGTH="20" class="input_chat">                         <input type="hidden" name="action" value="enter">                         <input type="hidden" name="chat" value="Entrou na sala - <?php echo $time; ?>">                         <input type="submit" name="Submit" value="Entrar" class="input_chat_enviar"></center></p> 			<p class="redirectfoot"><br></p> 		</div> 	</body>         </form> </html>   <?php  }  function Login() {          global $HTTP_SESSION_VARS;         global $chat;         global $nick;          session_start();         session_register("nick", $nick);         if ($skin=="") {         setCookie ("WSChat","padrão.css", time()+30240000);}   ?> <html> <head> <title>Clan World Stars - .:: CHAT ::.</title> </head>         <frameset rows="*,70" cols="*,115"  >           <frame name="posts" src="index.php?action=posts&nick=<?php echo $nick; ?>&chat=<?php echo $chat; ?>" scrolling="auto" noresize frameborder="0" border="0">           <frame name="user" src="index.php?action=users" scrolling="no" noresize" frameborder="0" border="0" >           <frame name="form" src="index.php?action=form&nick=<?php echo $nick; ?>" scrolling="no" noresize" frameborder="0" border="0" >           <frame name="logo" src="index.php?action=logo" scrolling="no" noresize" frameborder="0" border="0" >          </frameset>           <noframes>           <body>            <p>Seu navegador não suporta Iframes!</p>            </body>           </noframes>         </frameset> </html>   <?php }  function GetInput() {          global $HTTP_SESSION_VARS;         global $chat;         global $nick;         global $skin;         $skin = $_COOKIE["WSChat"];         $activedir = "./style/";         @chdir($activedir);   if ($skin=="") {   print '<link rel="stylesheet" href="./style/padrão.css" type="text/css">';}   else { ?> <link rel="stylesheet" href="<? echo $activedir.$skin; ?>" type="text/css"><?   }   ?>   <body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">         <form onSubmit="return doSubmit" name="chatform" method="post" action="index.php" target="posts" >   <table border="0" cellpadding="1" >  <tr>  <td valign="top" class="avatars">            <a href onClick="sendFace(1)"><img src="./img/smile.gif" alt=":)"></a>           <a href onClick="sendFace(2)"><img src="./img/frown.gif" alt=":("></a>           <a href onClick="sendFace(3)"><img src="./img/bigsmile.gif" alt=":D"></a>           <a href onClick="sendFace(4)"><img src="./img/angry.gif" alt=">("></a>           <a href onClick="sendFace(5)"><img src="./img/cool.gif" alt="8)"></a>           <a href onClick="sendFace(6)"><img src="./img/tongue.gif" alt=":P"></a>           <a href onClick="sendFace(7)"><img src="./img/huh.gif" alt="???"></a>           <a href onClick="sendFace(8)"><img src="./img/rolleyes.gif" alt="::)"></a>           <a href onClick="sendFace(9)"><img src="./img/embarassed.gif" alt=":-["></a>           <a href onClick="sendFace(10)"><img src="./img/lipsrsealed.gif" alt=":-X"></a>           <a href onClick="sendFace(11)"><img src="./img/kiss.gif" alt=":-*"></a>           <a href onClick="sendFace(12)"><img src="./img/cry.gif" alt=":'("></a>           <a href onClick="sendFace(13)"><img src="./img/undecided.gif" alt=":-\\"></a>           <a href onClick="sendFace(14)"><img src="./img/wink.gif" alt=";)"></a>  </td><td valign="top" > </td></tr>  <tr>   <td valign="top">            <input type="text" name="chat" size="35" MAXLENGTH=200 onkeypress="if (event.keyCode==13) setTimeout('document.chatform.chat.value=\'\'',20);">            <input type="hidden" name="nick"  value="<?php echo $nick; ?>">           <a href="java script:void(doSubmit())"         onMouseover="document.images['send'].src='./img/send2.gif'"         onMouseout ="document.images['send'].src='./img/send1.gif'">   <img src="./img/send1.gif" name="send" border=0 align="top"></a> </td> </tr></td>            <input type="hidden" name="action" value="posts"> <script language="JavaScript"> document.chatform.chat.focus(); </script>         </form> </table>       <script language="JavaScript">  function makecookie() { var expireDate = new Date expireDate.setMonth(expireDate.getMonth()+6) document.cookie = "skin=" + document.chatform.skin.value + "; expires=" + expireDate.toGMTString() parent.frames[1].document.location='index.php?action=users' parent.frames[3].document.location='index.php?action=logo' parent.frames[0].document.location='index.php?action=posts' parent.frames[2].document.location='index.php?action=form&nick=<?php echo $nick; ?>' document.chatform.chat.focus(); }              function sendFace(faceNum)           {             switch(faceNum)             {               case 1:                 document.chatform.chat.value = document.chatform.chat.value + ' :) ';                 break;               case 2:                 document.chatform.chat.value = document.chatform.chat.value + ' :( ';                 break;               case 3:                 document.chatform.chat.value = document.chatform.chat.value + ' :D ';                 break;               case 4:                 document.chatform.chat.value = document.chatform.chat.value + ' >( ';                 break;               case 5:                 document.chatform.chat.value = document.chatform.chat.value + ' 8) ';                 break;               case 6:                 document.chatform.chat.value = document.chatform.chat.value + ' :P ';                 break;               case 7:                 document.chatform.chat.value = document.chatform.chat.value + ' ??? ';                 break;               case 8:                 document.chatform.chat.value = document.chatform.chat.value + ' ::) ';                 break;               case 9:                 document.chatform.chat.value = document.chatform.chat.value + ' :-[ ';                 break;               case 10:                 document.chatform.chat.value = document.chatform.chat.value + ' :-X ';                 break;                case 11:                 document.chatform.chat.value = document.chatform.chat.value + ' :-* ';                 break;               case 12:                 document.chatform.chat.value = document.chatform.chat.value + ' :\'( ';                 break;               case 13:                 document.chatform.chat.value = document.chatform.chat.value + ' :-\\\ ';                 break;               case 14:                 document.chatform.chat.value = document.chatform.chat.value + ' ;) ';                 break;             }           document.chatform.chat.focus();            }          function doSubmit()         {           if(document.chatform.chat.value == '') {             alert('Favor, inserir algum texto!');             document.chatform.chat.focus();             return false;           }                 document.chatform.chat.value = document.chatform.chat.value;           document.chatform.submit();           document.chatform.chat.value = '';           document.chatform.chat.focus();           return true;         }         </script>   <?php }  function showlogo() {          global $HTTP_SESSION_VARS;         global $skin;         $activedir = "./style/";         @chdir($activedir);    if ($skin=="") {   print '<link rel="stylesheet" href="./style/padrão.css" type="text/css">';}   else { ?> <link rel="stylesheet" href="<? echo $activedir.$skin; ?>" type="text/css"><?   }   ?>   <body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">   <center>   <br>   <font face="arial" size="1" color="#000000">Desenvolvido por:</font>   <br>   <font face="arial" size="2" color="#000000"><b>Luan Stocco</b></font>   </center>     <?   } function ShowAddPosts() {          global $HTTP_SESSION_VARS;         global $chat;         global $nick;         global $timeoutseconds;         global $timestamp;         global $timeout;         global $skin;         $activedir = "./style/";         @chdir($activedir);         $timeoutseconds         = 250;         $timestamp=time();         $timeout=$timestamp-$timeoutseconds;            print '<meta http-equiv="refresh" content="10;URL=index.php?action=posts&nick='.$nick.'">';          echo '<body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">';    if ($skin=="") {   print '<link rel="stylesheet" href="./style/padrão.css" type="text/css">';}   else { ?> <link rel="stylesheet" href="<? echo $activedir.$skin; ?>" type="text/css"><?   }          include ("config.php");         $svrConn = mysql_connect("$host", "$user", "$pass") or die("<b>Error:</b> Não conseguimos conectar com o banco de dados!");         $dbConn = mysql_select_db("$base", $svrConn) or die ("<b>Error:</b> Não conseguimos encontrar a tabela do banco de dados!");         $chat = strip_tags($chat,'<i><b><a>');           if(!empty($chat)) {                  $strQuery = "insert into chatScript values(0, '$chat','$nick','$timestamp')";                 mysql_query($strQuery);         }           $strQuery = ("DELETE FROM chatScript WHERE timestamp<$timeout") or die("$useronline $base DELETE Error");          mysql_query($strQuery);          $strQuery = "select theText, theNick from chatScript order by pk_Id asc";         $chats = mysql_query($strQuery);            echo '<table border="0" width="100%" height="100%" cellpadding="1">            <tr><td  valign="top" align="left" width="80%" height="100%" class="chattext">';          while($chatline = mysql_fetch_array($chats)) {           print "<font size=\"2\"><b>" . $chatline["theNick"] . ":</b> " . swapFaces($chatline["theText"]) . "</b></i></font><br>";         }         echo '</td></tr></table>';         ?>         <script language="JavaScript">         scroll(10,600)         </script> <? }  function showusers() {         global $HTTP_SESSION_VARS;         global $nick;         global $skin;         $activedir = "./style/";         @chdir($activedir);         print '<meta http-equiv="refresh" content="15;URL=index.php?action=users">';         echo '<body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">';   if ($skin=="") {   print '<link rel="stylesheet" href="./style/padrão.css" type="text/css">';}   else { ?> <link rel="stylesheet" href="<? echo $activedir.$skin; ?>" type="text/css"><?   }           echo '<table border="0" width="100%" height="100%" cellpadding="1" >            <tr>';          echo '<td nowrap valign="top" align="left" width="20%" height="100%" class="online"><b>Usuários On-line:</b><br>';         include ("config.php");         $svrConn = mysql_connect("$host", "$user", "$pass") or die("<b>Error:</b> Não conseguimos conectar com o banco de dados!");         $dbConn = mysql_select_db("$base", $svrConn) or die ("<b>Error:</b> Não conseguimos encontrar a tabela do banco de dados!");         $nicks = array();         $strQuery = "select theNick from chatScript order by theNick asc";         $chats = mysql_query($strQuery);         while($chatline = mysql_fetch_array($chats)) {                         if (!in_array($chatline['theNick'],$nicks)) {                                 $nicks[] = $chatline['theNick'];                                 print "" . $chatline["theNick"] . "<br>";                         }          }       echo '</td></tr></table>';       }  function swapFaces($chatLine) {    $chatLine = str_replace("::)", "<img src='./img/rolleyes.gif'>", $chatLine);   $chatLine = str_replace(":)", "<img src='./img/smile.gif'>", $chatLine);   $chatLine = str_replace(":(", "<img src='./img/frown.gif'>", $chatLine);   $chatLine = str_replace(":D", "<img src='./img/bigsmile.gif'>", $chatLine);   $chatLine = str_replace(">(", "<img src='./img/angry.gif'>", $chatLine);   $chatLine = str_replace("8)", "<img src='./img/cool.gif'>", $chatLine);   $chatLine = str_replace(":P", "<img src='./img/tongue.gif'>", $chatLine);   $chatLine = str_replace("???", "<img src='./img/huh.gif'>", $chatLine);   $chatLine = str_replace(":-[", "<img src='./img/embarassed.gif'>", $chatLine);   $chatLine = str_replace(":-X", "<img src='./img/lipsrsealed.gif'>", $chatLine);   $chatLine = str_replace(':-\\', '<img src=\'./img/undecided.gif\'>', $chatLine);   $chatLine = str_replace(":-*", "<img src='./img/kiss.gif'>", $chatLine);   $chatLine = str_replace(":'(", "<img src='./img/cry.gif'>", $chatLine);   $chatLine = str_replace(";)", "<img src='./img/wink.gif'>", $chatLine);   return $chatLine; }  ?>[/codebox]   Aguardo..   Abraço