PHP/MySQL News with Comments - Adding comments
(Page 6 of 7 )
So, what’s left? We need to provide the backend for what happens when a user types in a comment. We will simply take the form input and insert it in the comments table. Then, provide a link back to the page they came from.
<?php function addComment($id) { global $db; /* insert the comment */ $query = "INSERT INTO news_comments " . "VALUES('',$id,'{$_POST['name']}'," . "'{$_POST['comment']}')"; mysql_query($query); echo "Comment entered. Thanks!<BR>\n"; echo "<a href=\"{$_SERVER['PHP_SELF']}" . "?action=show&id=$id\">Back</a>\n"; } ?> |
Next: Summing it up and final script >>
More Database Articles Articles
More By Matt Wade