prepare("SELECT * FROM main.user WHERE UPPER(username) LIKE UPPER(?)"); //weirdly, this requires a schema name $stmt->execute([$user]); $result = $stmt->fetch(PDO::FETCH_ASSOC); $bio = isset($result) ? $result['bio'] : 'This user has not set a bio.'; $stmt = $db->prepare("SELECT * FROM main.follow WHERE target = ?"); $stmt->execute([$user]); $following = $stmt->fetchAll(PDO::FETCH_DEFAULT); $stmt = $db->prepare("SELECT * FROM main.follow WHERE username = ?"); $stmt->execute([$user]); $followers = $stmt->fetchAll(PDO::FETCH_DEFAULT); $stmt = $db->prepare("SELECT * FROM main.role WHERE username = ?"); $stmt->execute([$user]); $roles = $stmt->fetchAll(PDO::FETCH_DEFAULT); } function follow() { global $db; global $username; global $user; $stmt = $db->prepare("SELECT * FROM main.follow WHERE username = ? AND target = ?"); $stmt->execute([$user,$username]); $result = $stmt->fetch(PDO::FETCH_ASSOC); if (is_null($username)) return; if ($result) { $stmt = $db->prepare("DELETE FROM main.follow WHERE username = ? AND target = ?"); $stmt->execute([$user,$username]); } else { $stmt = $db->prepare("INSERT INTO main.follow (username,target) VALUES (?,?)"); $stmt->execute([$user,$username]); } } function settings() { global $db; global $username; global $user; if (is_null($username)) return; $stmt = $db->prepare("DELETE FROM main.user WHERE username = ?"); $stmt->execute([$username]); $stmt = $db->prepare("INSERT INTO main.user (username,bio) VALUES (?,?)"); $stmt->execute([$username,$_POST['desc']]); move_uploaded_file($_FILES['avatar']['tmp_name'], $_SERVER["DOCUMENT_ROOT"] . '/../docs/pfp/' . $username . '.png'); } get_handler(); ?> 'Bio', 'type' => 'textarea', 'name' => 'desc', 'default' => $bio), array('key' => 'Avatar', 'type' => 'file', 'name' => 'avatar', 'default' => '') ),'/user.php?id=' . $user . '&type=settings'); } comments('user',$user); page_footer(); ?>