Ejemplo n.º 1
0
    $action = "";
}
if ($action == "add") {
    if (!empty($_POST)) {
        data_new($link, $_POST['name'], $_POST['value'], $_POST['discription'], $_POST['level']);
        header("Location: shop.php");
    }
    include "../views/add_shop.php";
} else {
    if ($action == "edit") {
        if (!isset($_GET['id'])) {
            header("Location: shop.php");
        }
        $id = (int) $_GET['id'];
        if (!empty($_POST) && $id > 0) {
            data_edit($link, $id, $_POST['name'], $_POST['value'], $_POST['discription'], $_POST['level']);
            header("Location: shop.php");
        }
        $data = data_get($link, $id);
        include "../views/add_shop.php";
    } else {
        if ($action == "delete") {
            $id = $_GET['id'];
            $data = data_delete($link, $id);
            header("Location: shop.php");
        } else {
            $data = data_all($link);
            include "../moduls/data_admin.php";
        }
    }
}
Ejemplo n.º 2
0
function data_administration_page($options)
{
    // Used to create links in the other functions.
    $options['path'] = $_GET['path'];
    $content = '';
    if (isset($_REQUEST['action'])) {
        switch ($_REQUEST['action']) {
            case 'delete':
                data_delete($options, $_GET['id']);
                break;
            case 'edit_form':
            case 'add_form':
                $content .= data_add_edit_form(isset($_GET['id']) ? $_GET['id'] : '', $options);
                break;
            case 'add_item':
            case 'edit_item':
                $content .= data_add_edit_form_process($_POST, $options);
                break;
        }
    }
    // If we didn't specify what we wanted to display, show the list of data.
    if ($content == '') {
        $content = data_list($options);
    }
    return $content;
}