rendered paste body<?php
session_start();
if(isset($_POST['shout'])){
include('connect.php');
mysql_select_db("secondthought129");
$username_shout = $_SESSION["username"];
$time = date('d/m/Y H:i');
$shout = mysql_real_escape_string(htmlspecialchars($_POST['shout']));
$postlen = strlen($shout);
$num_shouts = mysql_query("SELECT * FROM shoutbox");
$num_shouts = mysql_num_rows($num_shouts);
$num_shouts++;
if($postlen > 200){
die('Shout may not be more then 200 characters!');
}
$sql = "INSERT INTO `shoutbox` (`username`, `time`, `shout`, `shout_id`) VALUES ('$username_shout', '$time', '$shout', '$num_shouts');";
mysql_query($sql);
}
if(isset($_SESSION['username'])){
echo "
<form name='chatform' method='post' action='index.php'>
<table align='center' cellpadding='0' cellspacing='0'>
<tr>
<td colspan='2'>
<textarea name='shout' rows='4' class='textbox' style='width:140px;'></textarea>
</td>
</tr>
<tr>
<td>
<input type='submit' name='post_shout' value='Shout' class='button'>
</td>
</tr>
</table></form>";
}
else{
echo "You must be logged in to post shouts!<BR><BR>";
}
$result = mysql_query("SELECT * FROM shoutbox ORDER BY shout_id DESC");
while($row = mysql_fetch_array($result)){
echo "<span class='shoutboxname'>" . $row['username'] . "</span><br>";
echo "<span class='shoutboxdate'>" . $row['time'] . "</span><BR>";
echo "<span class='shoutbox'>" . $row['shout'] . "</span><br><BR>";
}
?>