Example #1
0
function find_selected_page()
{
    global $current_page;
    global $current_subject;
    if (isset($_GET["subject"])) {
        $current_subject = find_subject_by_id($_GET["subject"]);
        $current_page = find_default_page($current_subject["id"]);
    } elseif (isset($_GET["page"])) {
        $current_subject = null;
        $current_page = find_pages_by_id($_GET["page"]);
    } else {
        $current_page = null;
        $current_subject = null;
    }
}
Example #2
0
<?php

require_once "../includes/sessions.php";
require_once "../includes/db-connection.php";
require_once "../includes/functions.php";
?>

<?php 
$layout_context = "admin";
?>
 
<?php 
$current_page = find_pages_by_id($_GET["page"]);
if (!$current_page) {
    //subject id was missing or invalid or coudn'nt find on db
    redirect_to("manage_content.php");
}
$id = $current_page["id"];
$query = "DELETE FROM pages WHERE id = {$id} LIMIT 1";
$result = mysqli_query($connection, $query);
if ($result && mysqli_affected_rows($connection) == 1) {
    //sucess
    $_SESSION["message"] = "Page DELETED!";
    redirect_to("manage_content.php");
} else {
    //failure
    $_SESSION["message"] = "Page DELETION Failed";
    redirect_to("manage_content.php?page={$id}");
}