Merge pull request #20 from ThomasRubini/user_delete_method

This commit is contained in:
Thomas Rubini 2023-01-17 16:04:50 +01:00 committed by GitHub
commit d5eb4b0616
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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();
}
}