Hey everyone I've got a problem with a news script I'm trying to run on this site. Here's the 3 pages involved.
'newins.php'
<html>
<head>
</head>
<body bgcolor="#BEBE9B">
<table bgcolor="#CCCCCC" cellspacing="1" cellpadding="2">
<form action="newsprocess.php" method="POST">
<tr><td bgcolor="#BEBE9B"><font face="Arial" size="2"><b>User name: </td><td bgcolor="#BEBE9B"><input type="text" name="username" size="22"></td></tr>
<tr><td bgcolor="#BEBE9B"><font face="Arial" size="2"><b>News Topic: </td><td bgcolor="#BEBE9B"><input type="text" name="title" size="22"></td></tr>
<tr><td valign="top" bgcolor="#BEBE9B"></strong><font face="Arial" size="2"><b>News to post: </td><td bgcolor="#BEBE9B"><textarea cols="17" rows="5" name="news"></textarea></td></tr>
<tr><td colspan="2" align="right" bgcolor="#BEBE9B"><input type="submit" name="submit" value="Add news item"></td></tr>
</form>
</table>
</body>
</html>
'newsprocess.php'
<html>
<head>
</head>
<body>
<?
$username = $POST[username];
$news = $POST[news];
$topic = $_POST[title];
$conn = mysql_connect ("localhost", "dcevil", "nottellingawholeforum");
mysql_select_db("dcdb", $conn);
$sql = "INSERT INTO newstable values ('', '$username','$topic','$news')";
$result = mysql_query($sql, $conn) or die (mysql_error());
?>
</body>
</html>
'home.htm'
<html>
<head>
</head>
<body bgcolor="#BEBE9B">
<p><font face="Arial" size="3"><b><center>..::[HOME]::..</b></font></p>
<?
$conn = mysql_connect("localhost", "dcevil", "nottellingawholeforum");
mysql_select_db("dcdb", $conn);
$sql = "SELECT * FROM newstable ORDER BY id DESC LIMIT 0, 30 ";
$result = mysql_query($sql, $conn) or die (mysql_error());
print "<table border='0' width='75%' bordercolor='#CCCCCC' cellspacing='1' bgcolor='#999999'>";
while ( $postarray = mysql_fetch_array($result))
{
$id = $postarray['id'];
$user = $postarray['user'];
$topic = $postarray['topic'];
$message = $postarray['news'];
print "<tr><td bgcolor='#BEBE9B' align='right'><font face='Arial' size='2'><b>$topic</td></tr><tr><td bgcolor='#FFFFFF'><font face='Arial' size='2'>$news</td></tr>";
}
print "</table>";
?>
</body>
</html>
What's wrong with 'home.htm'? The first two pages work fine, and I can successfully add a news item to the database, but retreiving the data is proving very difficult. It just displays the HTML at the top of the page. Any ideas?