Commit 9d916fbe authored by Raphaël Peim's avatar Raphaël Peim

Finish backend tp2

parent 6ce27b74
......@@ -42,15 +42,12 @@
if(!empty($user)) {
$quest = "";
if (isset($post['name']) && isset($post['email']))
$quest = "UPDATE `users` SET `name` = '" . $post['name'] . "', `email` = '" . $post['email'] . "' WHERE `users`.`id` = " . $id;
else if (isset($post['name']) && !isset($post['email']))
$quest = "UPDATE `users` SET `name` = '" . $post['name'] . "' WHERE `users`.`id` = " . $id;
else if (!isset($post['name']) && isset($post['email']))
$quest = "UPDATE `users` SET `email` = '" . $post['email'] . "' WHERE `users`.`id` = " . $id;
print_r($post);
echo "\n";
if (isset($post->name) && isset($post->email))
$quest = "UPDATE `users` SET `name` = '" . $post->name . "', `email` = '" . $post->email . "' WHERE `users`.`id` = " . $id;
else if (isset($post->name) && !isset($post->email))
$quest = "UPDATE `users` SET `name` = '" . $post->name . "' WHERE `users`.`id` = " . $id;
else if (!isset($post->name) && isset($post->email))
$quest = "UPDATE `users` SET `email` = '" . $post->email . "' WHERE `users`.`id` = " . $id;
if ($quest != "") {
$request = DatabaseConnector::current()->prepare($quest);
......
......@@ -18,7 +18,7 @@
$response = $this->createUser($post);
break;
case 'PUT':
$response = $this->updateUser($post, $id);
$response = $this->updateUser(json_decode($post), $id);
break;
case 'DELETE':
$response = $this->deleteUser($id);
......
......@@ -47,7 +47,7 @@
break;
case 'user' :
$controller = new UsersController($requestMethod);
$controller->processRequest(fopen("php://input", "r"), $route['params'][0]);
$controller->processRequest(file_get_contents("php://input"), $route['params'][0]);
break;
default :
header("HTTP/1.1 404 Not Found");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment