shorty3 Posted August 3, 2010 Share Posted August 3, 2010 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> Quote Link to comment https://forums.phpfreaks.com/topic/209724-how-to-make-a-live-chat-from-my-php/ Share on other sites More sharing options...
Psycho Posted August 4, 2010 Share Posted August 4, 2010 One word (or acronym to be precise): AJAX Go find a tutorial and learn how to use it. StickyMinds.com actually had a tutorial using a chat system, but I think it is only available to subscribers, Quote Link to comment https://forums.phpfreaks.com/topic/209724-how-to-make-a-live-chat-from-my-php/#findComment-1094866 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.