Esempio n. 1
0
require_once "../includes/session.php";
require_once "../includes/db_connect.php";
require_once "../includes/functions.php";
require_once "../includes/validation_functions.php";
?>

<?php 
if (isset($_POST['submit'])) {
    $fields_required = array("username", "password");
    ValidatePresence($fields_required);
    $fields_with_max_lengths = array("username" => 40);
    ValidateMaxLengths($fields_with_max_lengths);
    $fields_with_max_lengths = array("username" => 40);
    ValidateMaxLengths($fields_with_max_lengths);
    if (empty($errors)) {
        $username = MysqlPrep($_POST["username"]);
        $hashed_password = PasswordEncrypt($_POST["password"]);
        $query = "INSERT INTO admins (";
        $query .= "username, hashed_password";
        $query .= ")  VALUES (";
        $query .= "  '{$username}', '{$hashed_password}' ";
        $query .= ")";
        $result = mysqli_query($db, $query);
        if ($result) {
            $_SESSION["message"] = "Admin user created.";
            RedirectTo("manage_admin.php");
        } else {
            $_SESSION["message"] = "Admin user creation failed";
        }
    }
} else {
Esempio n. 2
0
<?php 
include "../includes/layouts/admin-header.php";
?>


<?php 
if (isset($_POST['submit'])) {
    $fields_required = array("menu_name", "position", "visible");
    ValidatePresence($fields_required);
    $fields_with_max_lengths = array("menu_name" => 70);
    ValidateMaxLengths($fields_with_max_lengths);
    if (empty($errors)) {
        // Update
    }
    $id = $current_subject["id"];
    $menu_name = MysqlPrep($_POST["menu_name"]);
    $position = (int) $_POST["position"];
    $visible = (int) $_POST["visible"];
    $query = "UPDATE subjects SET ";
    $query .= "menu_name = '{$menu_name}' , ";
    $query .= "position = {$position} , ";
    $query .= "visible = {$visible}  ";
    $query .= "WHERE id = {$id} ";
    $query .= "LIMIT 1";
    $result = mysqli_query($db, $query);
    if ($result && mysqli_affected_rows($db) >= 0) {
        $_SESSION["message"] = "Subject updated.";
        RedirectTo("manage_content.php");
    } else {
        $message = "Subject update failed";
    }
Esempio n. 3
0
?>
 

<?php 
if (!$current_page) {
    RedirectTo("manage_content.php");
}
?>

<?php 
if (isset($_POST['submit'])) {
    $id = $current_page["id"];
    $menu_name = MysqlPrep($_POST["menu_name"]);
    $position = (int) $_POST["position"];
    $visible = (int) $_POST["visible"];
    $content = MysqlPrep($_POST["content"]);
    $fields_required = array("menu_name", "position", "visible", "content");
    ValidatePresence($fields_required);
    $fields_with_max_lengths = array("menu_name" => 70);
    ValidateMaxLengths($fields_with_max_lengths);
    if (empty($errors)) {
        $query = "UPDATE pages SET ";
        $query .= "menu_name = '{$menu_name}', ";
        $query .= "position = {$position}, ";
        $query .= "visible = {$visible}, ";
        $query .= "content = '{$content}' ";
        $query .= "WHERE id = {$id} ";
        $query .= "LIMIT 1";
        $result = mysqli_query($db, $query);
        if ($result && mysqli_affected_rows($db) == 1) {
            $_SESSION["message"] = "Page updated.";