<?php session_start(); require_once '../../inc/model/sessions.php'; require_once '../../inc/model/classes.php'; require_once '../../inc/model/functions.php'; require_once '../../inc/model/validation_func.php'; main\confirm_login(); main\find_selected_page(); if (isset($_POST["submit"])) { $username = main\mysql_prep($_POST["username"]); $password = main\password_encrypt($_POST["password"]); validation\no_null($username); $query = "INSERT INTO admins\n (username, hashed_password)\n VALUES\n ( '{$username}', '{$password}' )\n "; $result = $db->query($query); if ($result) { ?> <p class="alert alert-success"><?php $_SESSION["message"] = "Success!"; ?> </p><?php main\redirect_to("../manage_content.php"); } else { $_SESSION["message"] = "Fail!"; main\redirect_to("new_admin.php"); } } else { } include '../../inc/views/layouts/header.php'; main\menu($selected_subject_id, $selected_page_id); //include('../../inc/views/layouts/admin_header.php');
} ?> <?php if (isset($_POST['submit'])) { // validations $required_fields = array("menu_name", "position", "visible"); validation\validate_presences($required_fields); $fields_with_max_lengths = array("menu_name" => 30); validation\validate_max_lengths($fields_with_max_lengths); if ($_POST["menu_name"] == "") { $_SESSION["message"] = "You must enter a menu name"; main\redirect_to("../../index.php"); } $id = $current_subject["id"]; $menu_name = main\mysql_prep($_POST["menu_name"]); $position = (int) $_POST["position"]; $visible = (int) $_POST["visible"]; $query = "UPDATE subjects SET \n menu_name = '{$menu_name}', \n position = {$position}, \n visible = {$visible} \n WHERE id = {$id} \n LIMIT 1"; $result = $db->query($query); if ($result && mysqli_affected_rows($db) == 1) { // Success $_SESSION["message"] = "Subject updated."; main\redirect_to("../manage_content.php"); } else { // Failure $message = "Subject update failed."; } } else { // This is probably a GET request }
<?php session_start(); require_once '../../inc/model/sessions.php'; require_once '../../inc/model/classes.php'; require_once '../../inc/model/functions.php'; require_once '../../inc/model/validation_func.php'; main\confirm_login(); main\find_selected_page(); if (isset($_POST["submit"])) { $username = main\mysql_prep($_POST["username"]); $password = main\mysql_prep($_POST["password"]); $hash = main\find_all_admins(); validation\no_null($username); $query = "DELETE FROM admins\n WHERE username = '******'\n LIMIT 1"; $result = $db->query($query); if ($result) { $_SESSION["message"] = "Success!"; main\redirect_to("../manage_content.php"); } else { $_SESSION["message"] = "Fail!"; main\redirect_to("delete_admin.php"); } } else { } include '../../inc/views/layouts/header.php'; main\menu($selected_subject_id, $selected_page_id); //include('../../inc/views/layouts/admin_header.php'); ?> <div class="wrapper"> <section class="content">
$errors = array(); if (!$current_page) { main\redirect_to('../manage_content.php'); } ?> <?php if (isset($_POST['submit'])) { // validations $required_fields = array("menu_name", "position", "visible", "content"); validation\validate_presences($required_fields); $fields_with_max_lengths = array("menu_name" => 30); validation\validate_max_lengths($fields_with_max_lengths); $id = $current_page["id"]; $menu_name = main\mysql_prep($_POST["menu_name"]); $content = main\mysql_prep($_POST["content"]); $position = (int) $_POST["position"]; $visible = (int) $_POST["visible"]; $query = "UPDATE pages SET \n menu_name = '{$menu_name}',\n content = '{$content}',\n position = {$position}, \n visible = {$visible} \n WHERE id = {$id} \n LIMIT 1"; $result = $db->query($query); if ($result && mysqli_affected_rows($db) == 1) { // Success $_SESSION["message"] = "Page updated."; main\redirect_to("../manage_content.php"); } else { // Failure $message = "Page update failed."; } } else { // This is probably a GET request }