Passwords do not match! '; return $error_msg; } $password_hash = hash('sha256', $password); $id = rand(1000, 999999999); while (user_id_exists($id)) $id = rand(1000, 999999999); if (!empty($profile_picture)) { $filetype = explode('.', $profile_picture); $pic_path = $id . $filetype[count($filetype) - 1]; } $stmt = 'INSERT INTO user (user_id, username, email, password_hash, role_id' . (!empty($profile_picture) ? ', profile_picture' : '') . ') VALUES (' . $id . ', "' . $username . '", "' . $email . '", "' . $password_hash . '", ' . $role_id . (!empty($profile_picture) ? '", "' . $pic_path . '"' : '') . ');'; exec_statement($stmt, 0); login($username, $password, false); return true; } function login($username, $password, $stay_logged_in) { $password_hash = hash('sha256', $password); $query = 'SELECT user_id, username, email, role_id, profile_picture FROM user WHERE username ="' . $username . '" AND password_hash = "' . $password_hash . '";'; $user = query_one_result($query); if ($user == null) { $error_msg = '