update items
This commit is contained in:
parent
c0cfbd7df8
commit
f702c4c508
3 changed files with 39 additions and 22 deletions
|
@ -83,17 +83,20 @@ class Users{
|
||||||
|
|
||||||
$stmt = $this->conn->prepare("
|
$stmt = $this->conn->prepare("
|
||||||
UPDATE ".$this->itemsTable."
|
UPDATE ".$this->itemsTable."
|
||||||
SET name= ?, description = ?, price = ?, category_id = ?, created = ?
|
SET firstname= ?, lastname = ?, email = ?, password = ?, country = ?, birthdate = ?, permission = ?
|
||||||
WHERE id = ?");
|
WHERE id = ?");
|
||||||
|
|
||||||
$this->id = htmlspecialchars(strip_tags($this->id));
|
$this->id = htmlspecialchars(strip_tags($this->id));
|
||||||
$this->name = htmlspecialchars(strip_tags($this->name));
|
$this->firstname = htmlspecialchars(strip_tags($this->firstname));
|
||||||
$this->description = htmlspecialchars(strip_tags($this->description));
|
$this->lastname = htmlspecialchars(strip_tags($this->lastname));
|
||||||
$this->price = htmlspecialchars(strip_tags($this->price));
|
$this->email = htmlspecialchars(strip_tags($this->email));
|
||||||
$this->category_id = htmlspecialchars(strip_tags($this->category_id));
|
$this->password = htmlspecialchars(strip_tags($this->password));
|
||||||
$this->created = htmlspecialchars(strip_tags($this->created));
|
$this->country = htmlspecialchars(strip_tags($this->country));
|
||||||
|
$this->birthdate = htmlspecialchars(strip_tags($this->birthdate));
|
||||||
|
$this->permission = htmlspecialchars(strip_tags($this->permission));
|
||||||
|
|
||||||
$stmt->bind_param("ssiisi", $this->name, $this->description, $this->price, $this->category_id, $this->created, $this->id);
|
|
||||||
|
$stmt->bind_param("ssssssss", $this->firstname, $this->lastname, $this->email, $this->password, $this->country, $this->birthdate, $this->permission, $this->id);
|
||||||
|
|
||||||
if($stmt->execute()){
|
if($stmt->execute()){
|
||||||
return true;
|
return true;
|
||||||
|
|
10
docs/update-example.txt
Normal file
10
docs/update-example.txt
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"id": "hackergirl",
|
||||||
|
"firstname": "Emily",
|
||||||
|
"lastname":"Asgardius",
|
||||||
|
"email":"hackergirl@asgardius.company",
|
||||||
|
"password": "test",
|
||||||
|
"country":"asteroid",
|
||||||
|
"birthdate": "1994-02-19",
|
||||||
|
"permission": "admin"
|
||||||
|
}
|
|
@ -6,25 +6,29 @@ header("Access-Control-Max-Age: 3600");
|
||||||
header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
|
header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
|
||||||
|
|
||||||
include_once '../config/Database.php';
|
include_once '../config/Database.php';
|
||||||
include_once '../class/Items.php';
|
include_once '../class/Users.php';
|
||||||
|
|
||||||
$database = new Database();
|
$database = new Database();
|
||||||
$db = $database->getConnection();
|
$db = $database->getConnection();
|
||||||
|
|
||||||
$items = new Items($db);
|
$items = new Users($db);
|
||||||
|
|
||||||
$data = json_decode(file_get_contents("php://input"));
|
$data = json_decode(file_get_contents("php://input"));
|
||||||
|
|
||||||
if(!empty($data->id) && !empty($data->name) &&
|
if(!empty($data->id) && !empty($data->firstname) &&
|
||||||
!empty($data->description) && !empty($data->price) &&
|
!empty($data->lastname) && !empty($data->email) &&
|
||||||
!empty($data->category_id)){
|
!empty($data->password) && !empty($data->country) &&
|
||||||
|
!empty($data->birthdate) &&
|
||||||
|
!empty($data->permission)){
|
||||||
|
|
||||||
$items->id = $data->id;
|
$items->id = $data->id;
|
||||||
$items->name = $data->name;
|
$items->firstname = $data->firstname;
|
||||||
$items->description = $data->description;
|
$items->lastname = $data->lastname;
|
||||||
$items->price = $data->price;
|
$items->email = $data->email;
|
||||||
$items->category_id = $data->category_id;
|
$items->password = $data->password;
|
||||||
$items->created = date('Y-m-d H:i:s');
|
$items->country = $data->country;
|
||||||
|
$items->birthdate = $data->birthdate;
|
||||||
|
$items->permission = $data->permission;
|
||||||
|
|
||||||
|
|
||||||
if($items->update()){
|
if($items->update()){
|
||||||
|
|
Loading…
Reference in a new issue