Shoutbox @ vigge.net not working
Posted: Thu Feb 26, 2004 12:20 pm
After i developed my new outputting system @ http://www.vigge.net, the shoutbox on the right side of the page have stopped working for IE users.
THe shoutbox is designed to be included on a page, where, when it is, outputs a HTML-table with a shout-form, and under the form, an iframe which shows the latest shouts. when shouts are submitted by the shout-form, the form uses method POST with TARGET='shouts'. the shoutbox have worked before i changed the way the rest of the page is outputted, but before i show that code, i wanna know if I should change the submitting and design of the shoutbox.
Right now, what currently happens with IE-users when they submit a shout, is that the iframe reloads, but no shout is submitted, have a look at the code below, or visit http://www.vigge.net to check it yourselves.
Here's the code for shoutbox.php (form and iframe):
Shouts.php (the iframe, handling of submissions etc.., BTW; i know the echo_sb_head() function is ugly and bad, its just temporary):
Hope someone could help me solve this

THe shoutbox is designed to be included on a page, where, when it is, outputs a HTML-table with a shout-form, and under the form, an iframe which shows the latest shouts. when shouts are submitted by the shout-form, the form uses method POST with TARGET='shouts'. the shoutbox have worked before i changed the way the rest of the page is outputted, but before i show that code, i wanna know if I should change the submitting and design of the shoutbox.
Right now, what currently happens with IE-users when they submit a shout, is that the iframe reloads, but no shout is submitted, have a look at the code below, or visit http://www.vigge.net to check it yourselves.
Here's the code for shoutbox.php (form and iframe):
Code: Select all
<table class='content_tbl' border='1' align='center' cellspacing='2' width='200' cellpadding='1'>
<tr><td class='titlebar'>@shoutbox</td></tr>
<tr>
<td><form name='shout' method='post' action='shoutbox.php' target='shouts'>
<textarea name='shout_message' id='shout_message' cols='34' rows='3' maxlength='150' onKeyDown='textCounter(this.form.shout_message,this.form.lenght,150);' onKeyUp='textCounter(this.form.shout_message,this.form.lenght,150);'></textarea></td>
</tr>
<tr>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='submit' name='submit_shout' value='shout' onclick="javascript:clear_field(this.form.shout_message);">&nbsp;&nbsp;<input readonly='readonly' type='text' name='lenght' size='2' maxlength='3' value='150'> chars left</form></td>
</tr>
<tr>
<td valign='top'><iframe name='shouts' id='shouts' src='shoutbox.php' width='198' height='180' frameborder='0' scrolling='auto' allowtransparency='true'></iframe></td>
</tr>
<tr>
<td> <a href='shoutbox.php' target='shouts' class='button'>refresh shouts</a> </td>
</tr>
</table>Code: Select all
<?php
require_once ('modules/top.php'); // require top-file
############### submit shout ###############
if (!empty ($_POST['shout_message'])) { //Shout
if (!isSet($_SESSION['online']) || $_SESSION['online'] != true) { //Check if online
exit(); // prevent logged out users to shout
}
if ($_POST['submit_shout'] != "" && strlen($_POST['shout_message']) >= 6) {
$shout = addslashes(nl2br(htmlentities($_POST['shout_message'])));
$date = addslashes(date("H:i:s - D jS F Y"));
$query = "INSERT INTO shoutbox (date, nick, msg) VALUES ('$date', '{$_SESSION['username']}', '$shout')";
mysql_query($query);
$_SESSION['status'] = "shouted";
} else { $shout_msg = "Your shout must not contain less than 6 characters!"; }
}
############### /submit shout ###############
############### delete shout ###############
if (isSet($_GET['del']) && !empty($_GET['del'])) { //Delete a shout
//Load userlevel
$sql = "SELECT level FROM keeper WHERE nick = '{$_SESSION['username']}'";
$result = @mysql_fetch_row( @mysql_query($sql));
if ($result[0] >= 4) { //Only allow user with level above or at 4
$query4 = "DELETE FROM shoutbox WHERE id = {$_GET['del']}";
mysql_query($query4);
$shout_msg = "deleted shout (id: {$_GET['del']}).";
}
}
############### /delete shout ###############
############### output shouts ###############
## header
echo_sb_head("shouts");
require ('modules/format_string.php'); // include format_string function
if (!empty ($shout_msg)) { #### output shout message if there are any
echo "
<tr>
<td>
$shout_msg
</td>
</tr>
";
} ### /output shout message if there are any
$sql_shouts = "SELECT * FROM shoutbox ORDER BY id DESC LIMIT 20"; //Return 20 last shouts
$query_shouts = @mysql_query($sql_shouts);
while ($result_shouts = mysql_fetch_array ($query_shouts)) {
$sql_shouts2 = "SELECT level FROM keeper WHERE nick = '{$result_shouts['nick']}'";
$result_shouts2 = @mysql_fetch_array ( @mysql_query ($sql_shouts2));
//Load userlevel
$sql_shouts3 = "SELECT level FROM keeper WHERE nick = '{$_SESSION['username']}'";
$result_shouts3 = @mysql_fetch_row( @mysql_query($sql_shouts3));
if ($result_shouts3[0] >= 4) {
$adminopt = " | <a href='shoutbox.php?show=shouts&del={$result_shouts['id']}' title='Delete shout'>x</a>";
}
echo "
<tr><td>« ";
if ($result_shouts2['level'] > 3) { $usr_prefix = '@'; } else { $usr_prefix = ''; }; // if user is admin, print out an @ infront of the name
echo "<a href='profile.php?user={$result_shouts['nick']}' target='_parent' title='shouted at ".stripslashes($result_shouts['date'])."'>$usr_prefix{$result_shouts['nick']}</a>";
echo $adminopt;
echo " »<br>" . format_string (stripslashes ($result_shouts['msg'])) . "<br /></td></tr>";
}
## footer
echo_sb_head("footer");
############### /output shouts ###############
############### output-functions ###############
function echo_sb_head($op = "normal") { //Function echo_sb_head
require_once ('modules/skin.php'); // require get_skin function file
$usr_skin = get_skin ($_SESSION['username']);
if ($op == "footer") { //Echo footer
echo "
</table>
</BODY>
</HTML>";
} elseif ($op = "shouts") { //Echo shouts header
echo "
<HTML>
<HEAD>
<link rel='stylesheet' href='skins/{$usr_skin['file']}'>
</HEAD>
<BODY style='background-color:transparent'>
<table class='shouts' align='center' valign='top' cellspacing='0' cellpadding='3'>
";
} elseif ($op = "normal") { //Echo normal header
echo "
<HTML>
<HEAD>
<link rel='stylesheet' href='skins/{$usr_skin['file']}'>
</HEAD>
<BODY>
<table class='shouts' align='center' cellspacing='0' style='border: 0;'>
";
}
} //Function echo_sb_head
?>