From d0bb2e59b2f826bc36515f7180b479cb25d67418 Mon Sep 17 00:00:00 2001 From: Louis Vallat Date: Sun, 10 Nov 2019 00:15:03 +0100 Subject: [PATCH] forgot to add utils, now it should be better --- assets/php/utils.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/assets/php/utils.php b/assets/php/utils.php index 0fa1cb0..42d24db 100644 --- a/assets/php/utils.php +++ b/assets/php/utils.php @@ -182,3 +182,21 @@ function get_user_info_from_session_id($session_id, $info) } return false; } + +function add_user($email, $first_name, $last_name, $clear_password) +{ + global $PDO; + + $password_hash = password_hash($clear_password, PASSWORD_DEFAULT); + + $sql = "INSERT INTO accounts(email, first_name, last_name, password, public_id) + VALUES (:email, :first_name, :last_name, :password, :public_id);"; + $query = $PDO->prepare($sql); + $query->bindValue(":email", $email); + $query->bindValue(":first_name", $first_name); + $query->bindValue(":last_name", $last_name); + $query->bindValue(":password", $password_hash); + $query->bindValue(":public_id", generate_random_string()); + return $query->execute(); + return false; +}