I have a website where people can login . The site contains a forum,..... . Now I want integrate a chatroom. Does anyone know free chatroom code that is easy enough to integrate with my database of USERS ?
Or any other ideas?
Thanks
Chatroom with Users who logged in the website
Moderator: General Moderators
That room code is can be realy simple.
Make a frameset, with 2 frames (top,bottom).
top.php
And a bottom.php
Make a frameset, with 2 frames (top,bottom).
top.php
Code: Select all
<?php
mysql_connect('host','user','pass');
mysql_select_db('yours');
$last_id = 0;
while(TRUE){
$query = "SELECT
`user`.`username`,
`chat`.`line`,
`chat`.`id`
FROM `chat`
LEFT JOIN `user` ON `user`.`id` = `chat`.`user_id`
WHERE `chat`.`time` less then 5 min."
$result = mysql_query($query);
while($row = mysql_fetch_array($result)){
echo '<b>'.$row['user'].'</b>: '.$row['line'].'<br>';
$last_id = $row['id'];
}
sleep(1);
}
?>Code: Select all
<?php
if(isset($_REQUEST['line']))
{
mysql_connect('host','user','pass');
mysql_select_db('yours');
$query = "INSERT INTO `chat` (`user_id`,`line`,`time`) VALUES ('".$SESSION['user_id']."','".$_REQUEST['line']."',NOW())";
mysql_query($query);
}
?>
<form>
<input type="text" name="line">
</form>