$pid = intval($_POST['pid']); $aid = intval($_POST['aid']); if (isset($_POST['pid']) && $pid > 0) { $isPhoto = true; $id = $pid; } else { $isPhoto = false; $id = $aid; } //Error checking if (trim($_POST['comment']) == '') { //if comment is empty $msg->addError('PA_EMPTY_COMMENT'); //sql } else { $pa = new PhotoAlbum(); $result = $pa->addComment($id, $_POST['comment'], $_SESSION['member_id'], $isPhoto); if ($result) { //TODO: AJAX $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY'); } else { $msg->addError('PA_ADD_COMMENT_FAILED'); //sql } } if ($isPhoto) { header('Location: photo.php?pid=' . $pid . SEP . 'aid=' . $aid); } else { header('Location: albums.php?id=' . $aid); } exit;