PHP chat room help
Author |
Message |
Phenomena
|
Posted: Thu Mar 29, 2007 7:28 pm Post subject: PHP chat room help |
|
|
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) (site is currently down)
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 )
code: | <?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> |
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
Komstadter
|
Posted: Sun Apr 01, 2007 10:54 pm Post subject: RE:PHP chat room help |
|
|
http://www.php.net/manual/en/function.preg-replace.php
Edit: What you want to do is:
Array of bad words
For each bad word
$post = preg_replace(bad word, one * for each letter, $_POST['text']);
End For |
|
|
|
|
|
arun_sira
|
Posted: Tue Apr 10, 2007 4:50 am Post subject: RE:PHP chat room help |
|
|
actuall i want to run one script during run time. the script was available in database. how can i able to run the script.
Database contain table Script
In that Script table contain set of scripts, during run time, i want to run any one script from the table. |
|
|
|
|
|
|
|