include('db.class.php'); class comments{ private $comments; private $db; function __construct(db $db){ $this->db = $db; } public function load_comments(){ $comments = array(); $comms = $this->db->sql_select('comments'); if (mysql_num_rows($comms) > 0){ while($com = mysql_fetch_assoc($comms)){ $comments[] = $com; } } $this->comments = $comments; } public function add_comment($name, $text){ $this->db->raw_query('INSERT INTO comments (name, time, text) VALUES (\''.$name.'\', '.time().', \''.$text.'\')'); } public function display_comment_form(){ if (isset($_POST['submit']) && $_POST['submit'] == 'Add Comment'){ $messages = array(); if (empty($_POST['name'])) $messages[] = 'You need to enter a name'; if (empty($_POST['comment']) || $_POST['comment'] == 'Comment') $messages[] = 'You need to enter a comment'; if (empty($messages)){ self::add_comment($_POST['name'], $_POST['comment']); } else { print('