diff options
author | cflip <36554078+cflip@users.noreply.github.com> | 2021-04-24 19:40:50 -0600 |
---|---|---|
committer | cflip <36554078+cflip@users.noreply.github.com> | 2021-04-24 19:40:50 -0600 |
commit | 2098bf444afadcf0363d89b4cc1dca5d2213d754 (patch) | |
tree | da93b29e22170d7be7c9ed215fde5238e9d76178 /includes/functions_user.php | |
parent | aae25cd709d486f7ee9513753d40eb5cc239c42d (diff) |
Remove all uses of db_inc.php
This method of importing the database login every time wasn't very good.
Now everything uses the new Database singleton class.
Diffstat (limited to 'includes/functions_user.php')
-rw-r--r-- | includes/functions_user.php | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/includes/functions_user.php b/includes/functions_user.php new file mode 100644 index 0000000..b2069a2 --- /dev/null +++ b/includes/functions_user.php @@ -0,0 +1,21 @@ +<?php + +function username_exists(string $username): bool +{ + $sql = "SELECT * FROM users WHERE user_name = ?;"; + $result = Database::get()->query($sql, "s", $username); + + return !empty($result); +} + +function register_user(string $username, string $pass_hash) +{ + $sql = "INSERT INTO users(user_name, user_pass, user_date) VALUES(?, ?, NOW());"; + Database::get()->query($sql, "ss", $username, $pass_hash); +} + +function change_password(User $user, string $pass_hash) +{ + $sql = "UPDATE users SET user_pass = ? WHERE user_id = ?;"; + Database::get()->query($sql, "si", $pass_hash, $user->id); +}
\ No newline at end of file |