//xu ly from if (isset($_POST['delete']) && $_POST['delete'] == 'yes') { $q = "DELETE FROM pages WHERE page_id = {$pid} LIMIT 1"; $r = mysqli_query($dbc, $q); confirm_query($r, $q); if (mysqli_affected_rows($dbc) == 1) { $message = "<p class='success'>The pages was delete seccessflly</p>"; } else { $message = "<p class='warning'>The pages was not delete due to the system error</p>"; } } else { $message = "<p class='warning'>I thought so to ! shouldn't be deleted</p>"; } } } else { redirest_to('admin/view_pages.php'); } ?> <h2>Delete Category: <?php if (isset($page_name)) { echo $page_name; } ?> </h2> <?php if (isset($message)) { echo $message; } ?> <form action="" method="post"> <fieldset>
<?php include '../includes/header.php'; include '../includes/mysqli_connect.php'; include '../includes/functions.php'; include '../includes/sidebar-admin.php'; ?> <?php if (isset($_GET['pid']) && filter_var($_GET['pid'], FILTER_VALIDATE_INT, array('min_range' => 1))) { $pid = $_GET['pid']; } else { redirest_to('admin/admin.php'); } // xu ly form if ($_SERVER['REQUEST_METHOD'] == 'POST') { // gia tri toi tai xu ly form $errors = array(); //page name if (empty($_POST['page_name'])) { $errors[] = 'page_name'; } else { $page_name = mysqli_real_escape_string($dbc, strip_tags($_POST['page_name'])); } //cactegory if (isset($_POST['category']) && filter_var($_POST['category'], FILTER_VALIDATE_INT, array('min_range' => 1))) { $cat_id = $_POST['category']; } else { $errors[] = 'category'; } //position. if (isset($_POST['position']) && filter_var($_POST['position'], FILTER_VALIDATE_INT, array('min_range' => 1))) { $position = $_POST['position'];
$cat_name = $_POST['category']; } // kiem tra position cua categories if (isset($_POST['position']) && filter_var($_POST['position'], FILTER_VALIDATE_INT, array('min_range' => 1))) { $position = mysqli_real_escape_string($dbc, strip_tags($_POST['position'])); } else { $errors[] = "position"; } if (empty($errors)) { // neu ko co loi thi chen vao csdl $q = "UPDATE categories SET cat_name = '{$cat_name}', position = {$position} WHERE cat_id ={$cid} LIMIT 1"; $r = mysqli_query($dbc, $q); confirm_query($r, $q); if (mysqli_affected_rows($dbc) == 1) { $message = "<p class='success'> The categories was updated successfly</p>"; redirest_to('admin/view_categories.php'); } else { $message = "<p class='warning'>COuld not the update categories due to the systom error</p>"; } } else { $message = "<p class='warning'>Please fill all the required flieds</p>"; } } //END main if ?> <div id="content"> <?php $q = "SELECT cat_name, position FROM categories WHERE cat_id={$cid}"; $r = mysqli_query($dbc, $q); confirm_query($r, $q); if (mysqli_num_rows($r) == 1) {
<?php include 'includes/mysqli_connect.php'; include 'includes/functions.php'; if ($pid = validate_id($_GET['pid'])) { // neu ton tai bien pid thi tiep tuc truy van csdl $set = get_page_by_id($pid); $posts = array(); if (mysqli_num_rows($set) > 0) { $pages = mysqli_fetch_array($set, MYSQLI_ASSOC); $title = $pages['page_name']; $posts[] = array('page_name' => $pages['page_name'], 'content' => $pages['content'], 'author' => $pages['name'], 'post-on' => $pages['date'], 'aid' => $pages['user_id']); } } else { redirest_to(); } include 'includes/header.php'; include 'includes/sidebar-a.php'; ?> <div id="content"> <?php foreach ($posts as $post) { echo "\n <div class='post'>\n <h2>" . $post['page_name'] . "</h2>\n <p>" . the_content($post['content']) . "</p>\n <p class='meta'><strong>Posted by: </strong><a href='author.php?aid={$post['aid']}'>" . $post['author'] . "</a> | <strong>On: </strong>" . $post['post-on'] . "</p>\n\n </div>\n "; } ?> <?php include 'includes/comment_form.php'; ?> </div><!--end content--> <?php include 'includes/sidebar-b.php';