Add user/delete method

This commit is contained in:
Thomas Rubini 2023-01-17 16:03:49 +01:00
parent d0802ea4c9
commit f3109c51a0
No known key found for this signature in database
GPG Key ID: C7D287C8C1CAC373
2 changed files with 21 additions and 0 deletions

View File

@ -132,4 +132,18 @@ final class UserController
header("Location: /user");
}
public function deleteAction(Array $A_urlParams = null, Array $A_postParams = null)
{
Session::login_or_die();
$O_userModel = new UserModel();
$O_userModel->deleteByID($_SESSION["ID"]);
Session::destroy_session();
header("Location: /");
}
}

View File

@ -85,4 +85,11 @@ final class UserModel
$stmt->bindParam("new_username", $S_newUsername);
$stmt->execute();
}
public function deleteByID($I_id){
$O_model = Model::get();
$stmt = $O_model->prepare("DELETE FROM USER WHERE ID=:id");
$stmt->bindParam("id", $I_id);
$stmt->execute();
}
}