<?php include_once '../Model/Meal.php'; $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null; $method = $_SERVER['REQUEST_METHOD']; $format = isset($_REQUEST['format']) ? $_REQUEST['format'] : 'web'; $view = null; switch ($action . '_' . $method) { case 'create_GET': $model = Meal::Blank(); $view = "meals/edit.php"; break; case 'save_POST': $sub_action = empty($_REQUEST['id']) ? 'created' : 'updated'; $errors = Meal::Validate($_REQUEST); if (!$errors) { $errors = Meal::Save($_REQUEST); } if (!$errors) { if ($format == 'json') { header("Location: ?action=edit&format=json&id={$_REQUEST['id']}"); } else { header("Location: ?sub_action={$sub_action}&id={$_REQUEST['id']}"); } die; } else { //my_print($errors); $model = $_REQUEST; $view = "meals/edit.php"; } break;
<?php include_once '../Model/meal.php'; $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null; $method = $_SERVER['REQUEST_METHOD']; $format = isset($_REQUEST['format']) ? $_REQUEST['format'] : 'web'; $view = null; switch ($action . '_' . $method) { case 'create_GET': $meals = Meal::Blank(); $view = "meals/edit.php"; break; case 'save_POST': $sub_action = empty($_REQUEST['id']) ? 'created' : 'updated'; $errors = Meal::Validate($_REQUEST); if (!$errors) { $errors = Meal::Save($_REQUEST); } if (!$errors) { if ($format == 'json') { header("Location: ?action=edit&format=json&id={$_REQUEST['id']}"); } else { header("Location: ?sub_action={$sub_action}&id={$_REQUEST['id']}"); } die; } else { $meals = $_REQUEST; $view = "meals/edit.php"; } break; case 'edit_GET':