Reloade efter besked i chat
Hej.. På www.nbainfo.dk er der en lille chat ude til højre.. Det er siden shoutbox.php.Hele koden ser således ud:
<?
if ($settings[guestposts] == "1") {
$shoutbox = "<form name=\"chatform\" method=\"post\" action=\"$PHP_SELF\">
Navn:<br>
<input type=\"textbox\" name=\"shoutname\" value=\"$userdata[user_name]\" class=\"textbox\" maxlength=\"32\" style=\"width:100%;\"><br>
Besked:<br>
<textarea name=\"shout_message\" rows=\"3\" class=\"textbox\" style=\"width:100%;\"></textarea><br>
<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">
<tr><td>
<input type=\"submit\" name=\"post_shout\" value=\"Shout\" class=\"button\" style=\"width:80px;\"></td>
<td align=\"right\"><a href=\"shoutboxhelp.php\" class=\"slink\">Hjælp</a></td></tr>
</table>
</form><br>\n";
} else {
if ($userdata[user_name] != "") {
$shoutbox = "<form name=\"shoutform\" method=\"post\" action=\"$PHP_SELF\">
Besked:<br>
<textarea name=\"shout_message\" rows=\"3\" class=\"textbox\" style=\"width: 100%;\"></textarea><br>
<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">
<tr><td>
<input type=\"submit\" name=\"post_shout\" value=\"Shout\" class=\"button\" style=\"width: 80px;\"></td>
<td align=\"right\"><a href=\"shoutboxhelp.php\" class=\"slink\">Hjælp</a></td></tr>
</table>
</form><br>\n";
} else {
$shoutbox = "<center>Du skal være logget ind for at skrive en besked</center><br>\n";
}
}
$result = dbquery("SELECT count(shout_id) FROM ".$x2_prefix."shoutbox");
$rows = dbresult($result, 0);
$result = dbquery("SELECT * FROM ".$x2_prefix."shoutbox ORDER BY shout_datestamp DESC LIMIT 0,".$settings[numofshouts]);
if (dbrows($result) != 0) {
$i = 1;
while ($data = dbarray($result)) {
$shout_message = stripslashes($data[shout_message]);
$shout_message = parsesmileys($shout_message);
$postee = explode(".", $data[shout_name]);
$shoutbox .= "<div class=\"shoutboxname\">";
if ($postee[0] != 0) {
$shoutbox .= "<a href=\"profile.php?lookup=$postee[0]\" class=\"slink\">$postee[1]</a>";
} else {
$shoutbox .= "$postee[1]";
}
$shoutbox .= "</div>
<div align=\"left\" class=\"shoutbox\">$shout_message</div>
<div class=\"shoutboxdate\">".strftime($settings[shortdate], $data[shout_datestamp]+($settings[timeoffset]*3600))."</div>\n";
}
if ($rows > 10) {
$shoutbox .= "<center><br>
[<a href=\"shoutbox_archive.php\" class=\"slink\">Chat arkiv</a>]</center>\n";
}
} else {
$shoutbox .= "<div align=\"left\">no messages have been posted.</div>\n";
}
openside("Chat");
echo "$shoutbox";
closeside();
?>
Kan jeg få siden til at refreshe, når der er skrevet en besked? Eller hvordan kan jeg ellers få en eller anden form for autoreload på?
