<?php require_once __DIR__ . '/../common/autoload_cms.php'; if ($_SERVER['REQUEST_METHOD'] === 'POST') { $entity = new Menu(); $entity->setTitle($_POST['title'])->setUrl($_POST['url']); $menuCollection = new MenuCollection(); $menuCollection->save($entity); header('Location: menu_list.php'); exit; } require_once 'include/header.php'; ?> <div class="container"> <form method="post" action="" enctype="multipart/form-data"> <div class="form-group"> <label for="title">Title:</label> <input type="text" name="title" id="title" class="form-control"> </div> <div class="form-group"> <label for="url">URL:</label> <input type="text" name="url" id="url" class="form-control"> </div> <button type="submit" class="btn btn-default">Submit</button> </form> </div>
<?php require_once __DIR__ . '/../common/autoload_cms.php'; $menuCollection = new MenuCollection(); $menu = $menuCollection->one(array('id' => $_GET['id'])); if ($_SERVER['REQUEST_METHOD'] === 'POST') { $menu->setTitle($_POST['title'])->setUrl($_POST['url']); $menuCollection->save($menu); header('Location: menu_list.php'); exit; } require_once 'include/header.php'; ?> <div class="container"> <form method="post" action="" enctype="multipart/form-data"> <div class="form-group"> <label for="title">Title:</label> <input type="text" name="title" id="title" value="<?php echo $menu->getTitle(); ?> " class="form-control"> </div> <div class="form-group"> <label for="url">URL:</label> <input type="text" name="url" id="url" value="<?php echo $menu->getUrl(); ?>