use MealBooker\model\Dessert; use MealBooker\models\dao\DessertDao; if (!SecurityManager::get()->getCurrentUser($_SESSION)->isAdmin()) { header('Location:' . WEB_PATH); } $dessertDao = new DessertDao($em); //save mode if (isset($_POST['name']) && isset($_POST['desc']) && isset($_POST['id']) && isset($_POST['state'])) { $dessert = $dessertDao->getByPrimaryKey($_POST['id']); if ($dessert == null) { $dessert = new Dessert(); } $dessert->setName($_POST['name']); $dessert->setDescription($_POST['desc']); $dessert->setStatus($_POST['state']); $dessertDao->save($dessert); header('Location:' . WEB_PATH . '?page=admin&tab=dessert'); } //view Mode if (isset($_GET['id'])) { $dessert = $dessertDao->getByPrimaryKey($_GET['id']); if ($dessert == null) { header('Location:' . WEB_PATH); } } else { $dessert = new Dessert(); } ?> <div class="row"> <div class="col-md-4 col-md-offset-4"> <form action="#" method="post" class="form">