. */ require_once('./conf.php'); $response = new response(); try { $assignment = new assignment($_pdo, $_REQUEST['pk']); $name = explode('-', $_REQUEST['name']); $what_to_edit = $name[count($name) - 1]; switch ($what_to_edit) { case 'title': $response->success = $assignment->setTitle($_REQUEST['value']); break; case 'hours': $response->success = $assignment->setHours($_REQUEST['value']); break; case 'price_per_hour': $response->success = $assignment->setPricePerHour($_REQUEST['value']); break; case 'vat': $response->success = $assignment->setVAT($_REQUEST['value']); break; default: $response->http_response_code(404); $response->success = false; } if (!$response->success && $response->http_response_code() == 200) { $response->http_response_code(500); $response->message = "The assignment could not be edited due to an error."; } } catch (PDOException $e) { $response->http_response_code(500); $response->success = false; $response->message = "The assignment could not be edited due to a PDO error ({$e->getMessage()})."; } catch (Exception $e) { $response->http_response_code(404); $response->success = false; $response->message = "The assignment could not be edited due to an exception."; } echo $response->message;