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; +}