$OUTPUT = balance(); break; case "balance_update": $OUTPUT = balance_update(); break; case "reason": $OUTPUT = reason(); break; case "reason_update": $OUTPUT = reason_update(); break; case "comments": $OUTPUT = comments(); break; case "comments_update": $OUTPUT = comments_update(); break; } } else { $OUTPUT = select(); } require "template.php"; function select($message = "") { extract($_REQUEST); $fields = array(); $fields["search"] = ""; extract($fields, EXTR_SKIP); if (empty($search)) { $search = "[(EMPTY SEARCH FIELD)]"; }
<?php $message = ''; $title = ''; if (!isset($_GET['id'])) { //note id is not specified go back to notes-list page header('location: ?p=viewComments'); exit; } $id = intval($_GET['id']); //check if button submit is clicked if (isset($_POST['submit'])) { $name = trim($_POST['name']); $comment = trim($_POST['comment']); if ($name != '' and $comment != '') { comments_update($id, $name, $comment); $message = "<div class = 'alert alert-success' style = 'width: 300px;'>Selected comment has been updated.</div>"; echo "<script>"; //go back to viewComments page after 3 seconds. echo "setTimeout(function(){ document.location = '?p=viewComments'; }, 2000);"; echo "</script>"; } else { $message = "<div class = 'alert alert-success' style = 'width: 300px;'>Please input name and comments..</div>"; } } else { //if not submitted we retrieve the data from the database $comments = comments_find($id); if ($comments) { $name = $comments['name']; $comment = $comments['comments']; } else {
<?php //Update comment section require_once '../includes/functions.inc.php'; require_once '../includes/admin.inc.php'; if (isset($_POST['pid'])) { $pid = $_POST['pid']; print comments_update($pid); }