From c50a323c25a0787ba2051b19721983776a229615 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Thu, 5 Feb 2015 00:40:47 +0100 Subject: Initial commit --- include/contacts-new.php | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 include/contacts-new.php (limited to 'include/contacts-new.php') diff --git a/include/contacts-new.php b/include/contacts-new.php new file mode 100644 index 0000000..c04fa72 --- /dev/null +++ b/include/contacts-new.php @@ -0,0 +1,47 @@ +. + */ + +require_once('./conf.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->getName()} 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(); \ No newline at end of file -- cgit v1.2.3