Well, please forgive for beeing such a bonehead, but I could really use some help on this one... I'm trying to include an extra field to guestbook table for admin comments. So far I have added the field and I have also altered act_guestbook.php to look for that particular field. So far so good. Now comes the tricky part for me:
Lets assume I would like to insert or alter the information of the field. What kind of query I should compose? This is what I have come up with, but it doesn't work.
Code: Select all
if(isset($_POST["add_comment"])) {
$sql = "UPDATE ".DB_PREPEND."phpwcms_guestbook SET ";
$sql .= "guestbook_comment=".strval($_POST['cguestbook_comment'])." WHERE guestbook_cid=";
$sql .= intval($_POST['cid'])." AND guestbook_id=".intval($_POST['guestbook_id']);
mysql_query($sql, $db);
}
This is the form I've created:
Code: Select all
<form action="act_guestbook.php" method="post"><input type="hidden" name="add_comment" value="10"><input type="hidden" name="cid" value="'.$row['guestbook_cid'].'"><input type="hidden" name="guestbook_id" value="'.$row['guestbook_id'].'"><textarea rows="2" cols="40" name="cguestbook_comment" wrap="VIRTUAL">'.htmlspecialchars($row['guestbook_comment']).'</textarea><input type="image" src="../../img/button/edit_22x11.gif" value="submit"></form>
Edit: if you can help me with this, could you also be so kind to tell that for me like I'm a 4-year old? I would really like to learn.