Example #1
0
if (isset($_GET['delete']) && is_numeric($_GET['delete'])) {
    $controller->delete($_GET['delete'], "categories");
}
// Create new category
if (isset($_POST['submit'])) {
    $uploadErrors = array();
    $category = "";
    if (isset($_POST['name']) && $_POST['name'] == "") {
        $uploadErrors[] = "name";
    } else {
        $name = $_POST['name'];
    }
    // Check if we had any errors in the form
    if (count($uploadErrors) == 0) {
        // Add category to the database
        if ($controller->addCategory($name)) {
            // Success
            echo "<span class='text-success'>Category {$name} created</span>";
        } else {
            // Fail
            echo "<span class='text-danger'>Category {$name} could not be created</span>";
        }
    }
}
?>
    <div class="container">
        <div class="starter-template">
            <h1>Create a new category</h1>
            <form action="" method="post" enctype="multipart/form-data">
                Category name:
                <input type="text" name="name">