Allright,
well i'm devloping this small app that is like a blog/update type of thing, so far i've got it all figured out. However i'm stuck in one section, comments.
the comments are working, you can post a comment and it will go, however, it is not posted under any posts.
Yes i've created the sql database table, with an id field, set as INT and not null.
Now i've experimented with it, and if i add an id to the field, the comment is posted into the right post, but thats only if i do it through the databse. So i know it has do with some of the code ihave or the way i set it up, i just don't know what else to try.
So i need some help from people who know their way around php.
The code that proccess the form is posted below
<?php
require_once("config.php");
$id = intval($_REQUEST["id"]);
$sql = "SELECT title FROM updates WHERE id = $id";
$result = mysql_query($sql, $connection) or die(mysql_error());
if (mysql_num_rows($result) != 0) {
header("Location: index.php");
exit;
}
$name = mysql_escape_string(strip_tags($_REQUEST['name']));
$email = ($_REQUEST['email']);
$comment = mysql_escape_string(strip_tags($_REQUEST['comment']));
$comment = nl2br($comment);
$sql="INSERT INTO comments (name, email, comment, id)
VALUES
('$_POST[name]','$_POST[email]','$_POST[comment]','$_POST[id]')";
if (!mysql_query($sql,$connection))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
?>
The form itself is posted below
<form method="POST" action="comment.php">
<table width="500" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2"><input type="hidden" name="id" value="'$id"></td>
</tr>
<tr>
<td width="135">Name</td>
<td width="365"><label>
<input type="text" name="name" id="name">
</label></td>
</tr>
<tr>
<td>Email</td>
<td><label>
<input type="text" name="email" id="email">
</label></td>
</tr>
<tr>
<td>Comments</td>
<td><label>
<textarea name="comment" id="comment" cols="45" rows="5"></textarea>
</label></td>
</tr>
<tr>
<td colspan="2"><label>
<input type="submit" name="submit" id="submit" value="Post Comment">
</label></td>
</tr>
</table>
</form>
So if any know can help me point what i've done wrong that i can't see i would gladly help!
Thank you!