echo "MESSAGE: route removed"; } if (isset($_POST['edit']) && isset($_POST['id'])) { $edit = 1; $route = new routes(); $routeId = $_POST['id']; $allRoutes = $route->getAll(); $selectedRoute = $route->get('*', $allRoutes[$routeId]['id']); $smarty->assign('edit', $edit); $smarty->assign('selectedRoute', $selectedRoute); } if (isset($_POST['done_edit'])) { $route = new routes(); $routeId = $_POST['id']; $allRoutes = $route->getAll(); $route->update($allRoutes[$routeId]['id'], $_POST['city1'], $_POST['city2'], $_POST['expense'], $_POST['income']); echo "MESSAGE: route edited"; } $route = new routes(); $allRoutes = $route->getAll(); $smarty->assign('allRoutes', $allRoutes); $smarty->display('manage_routes.tpl'); $smarty->display('footer.tpl'); //include footer file } else { header('Location:' . URL . 'notauthorised.php'); } } else { header('Location:' . URL . 'noaccess.php'); } ?>