So I'm working on my first real php project. I'm still learning but I think im off to good a start. I started to create a simple chat room for learning purpose.
(http://modhalotrial.com/php_stuff/chat_room)
I just need help with a few things how do i create censored words (using the mysql db with the tables id, before, after) and an auto refresh for the chat because right now new posts only show up when you post or refresh
heres my code (remember im still new at this so dont tear it shreds )
<?php
require ('config.php');
mysql_connect ($server,$user,$pass) or die("Could not connect to server.");
@mysql_select_db ($database);
$user = $_POST['user2'];
$post = $_POST['text'];
$date = date("H:i:s");
$query = "INSERT INTO chat VALUES ('','$post','$date','$user')";
mysql_query($query);
?>
<table border="2" cellpadding="5" width="650" height="600">
<tr>
<td align="left" ><font size="2">
<?php
$query2 = "SELECT * FROM chat";
$result = mysql_query($query2);
$num = mysql_numrows($result);
$i = 0;
while ($i < $num)
{
$user3=mysql_result($result,$i,user);
$chat=mysql_result($result,$i,message);
$date=mysql_result($result,$i,date);
echo "<b>$user3</b>, <i>$date</i> - $chat<br>";
$i++;
}
?>
</font>
</td>
<td align="center" width="175">
Chatters
</td>
</tr>
<td colspan="2" align="center" height="65">
<form action="chat.php" method="post">
User: <input type="text" name="user2" value="<?php if ($user == "")
{
echo "Anonymous";
}
else
{
echo $user;
} ?>" onChange="this.value='Locked text!';" size=12 readonly>
Message: <input type="text" name="text" size="50">
<input type="submit" value="Submit">
</form>
<?php
$n = 0;
while ($n < 20)
{
$emot = "emoticons/$n.gif\"";
echo "<img src=\"http://modhalotrial.com/php_stuff/chat_room/$emot>";
$n++;
}
?>
</td>
</table>