a Comment system for a update list, I got it up and running, it records the text input and the article that was commented on, but not the ID and display name.
The PHP script is as follows
Code: Select all
<b><center>Comments on this article</center></b>
<?php
$result = mysql_query("SELECT player, display_name, article, comment FROM comments WHERE article=$number");
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
printf(" Comment made by <a href=profile.php?id=%s><b>%s</b></a></br>%s<hr>", $row["player"], $row["display_name"], $row["comment"]);
}
mysql_free_result($result);
if(isset($_POST['save']))
{
$content = $_POST['content'];
if(!get_magic_quotes_gpc())
{
$content = addslashes($content);
}
$query = "INSERT INTO `comments` (`player`, `display_name`, `article`, `comment`) VALUES ('$users->id', '$users->display_name', '$number', '$content');";
mysql_query($query) or die('Error ,query failed');
echo "Comment added";
}
?>
<form method="post">
<table border="0" cellpadding="2" cellspacing="1" class="box" align="center">
<tr>
<td>Content</td>
<td><textarea name="content" cols="50" rows="10" class="box" id="content"></textarea></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan="2" align="center"><input name="save" type="submit" class="box" id="save" value="Post comment"></td>
</tr>
</table>
</form>Code: Select all
<b><center>Comments on this article</center></b>
Comment made by <a href=profile.php?id=0><b></b></a></br>Why no worky?<hr>Code: Select all
<b><center>Comments on this article</center></b>
Comment made by <a href=profile.php?id=1><b>Me</b></a></br>That is better<hr>What am i doing wrong? do i have to include the ID and name is the form or is the code that gets the id wrong?
EDIT: This is included on anohter page