Jump to content

how to make a live chat from my php?


shorty3

Recommended Posts

i want to add a chat feature on my site but its got to be live so it like reloads every 1 secound but no the whole page just the chat

 

i have this

 

<?php
session_start();
include "includes/db_connect.php"; include "includes/functions.php"; logincheck();
$username=$_SESSION['username'];
$query=mysql_query("SELECT * FROM users WHERE username='$username' LIMIT 1");
$fetch=mysql_fetch_object($query);


?>




<link rel=stylesheet href=includes/in.css type=text/css>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">


<body>
<div id="moniter"><table class=thinline width="15%" border="1" align="center" cellpadding="2" cellspacing="0" bordercolor=black>
  <tr>
    <td background="includes/grad.jpg"><center class=bold>Latest updates</center></td>
  </tr>

  <tr>
    <td>
<?php
$select_updates=mysql_query("SELECT * FROM chat ORDER BY id DESC");
while($the=mysql_fetch_object($select_updates)){
echo "[$the->time] <A href='profile.php?viewuser=$the->username'>$the->username</a>: $the->message<br>";
}
?>

</td>
  </tr>
</table></div>
<br>
<br>
<?php
if (strip_tags($_POST['submit']) && (strip_tags($_POST['update'] != ""))){
$update=strip_tags($_POST['update']);
$date = gmdate('Y-m-d h:i:s');
mysql_query("INSERT INTO `chat` ( `id` , `username` , `time` , `message` ) 
VALUES (
'', '$username', '$date', '$update'
)");
echo "<META HTTP-EQUIV='Refresh' CONTENT='0; URL=chat.php'>";
}


?>
<form name="form1" method="post" action="">
  <table width="15%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000" class="thinline">
    <tr> 
      <td height="20"><center>Add a update
      </center></td>
    </tr>
    <tr> 
      <td><table width="100%" border="0" cellspacing="0" cellpadding="0" >
          <tr> 
            <td colspan="2"> 
                <textarea name="update" cols="80" rows="5" id="update" class="text_box2"></textarea>
            </td>
          </tr>
          <tr> 
            <td width="86%"> </td>
            <td width="14%"><input name="submit" type="submit" id="submit" value="Add update"></td>
          </tr>
        </table></td>
    </tr>
  </table>
</form>

<?php include_once"includes/footer.php"; ?>


</body>
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.