. */ require_once(__DIR__ . '/../conf.php'); require_once(__DIR__ . '/../login-ajax.php'); $response = new Response(); try { $client = new Client($_pdo, $_REQUEST['clientId']); $contact = $client->createContact( $_REQUEST['name'], $_REQUEST['email'], $_REQUEST['address'], $_REQUEST['address_2'], $_REQUEST['postal_code'], $_REQUEST['city'], $_REQUEST['country'] ); $response->success = true; $response->message = "Contact {$contact->name} has been succesfully created. Refresh the page."; } catch (PDOException $e) { $response->http_response_code(500); $response->success = false; $response->message = "The contact could not be created due to a PDO error ({$e->getMessage()})."; } catch (Exception $e) { $response->http_response_code(404); $response->success = false; $response->message = "The contact could not be created due to an error."; } echo $response->getJson();