prepare("SELECT id FROM users WHERE username = ?"); $stmt->execute([$username]); return $stmt->fetchColumn(); } // Function to get user's domains function getUserDomains($userId, $pdo) { $stmt = $pdo->prepare("SELECT id, domain_name, ip_address FROM domains WHERE user_id = ?"); // Fetching ip_address $stmt->execute([$userId]); return $stmt->fetchAll(); } // Function to remove a domain function removeDomain($domainId, $pdo) { $stmt = $pdo->prepare("DELETE FROM domains WHERE id = ?"); $stmt->execute([$domainId]); } // Function to update domain's IP address function updateDomainIP($domainId, $ipAddress, $pdo) { $stmt = $pdo->prepare("UPDATE domains SET ip_address = ? WHERE id = ?"); // Updating ip_address $stmt->execute([$ipAddress, $domainId]); } // Handle domain removal if (isset($_GET['remove'])) { removeDomain($_GET['remove'], $pdo); header("Location: https://tildenic.org/?page=user_domains"); exit; } // Handle IP address update if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['update_ip'])) { $domainId = $_POST['domain_id']; $ipAddress = $_POST['ip_address']; updateDomainIP($domainId, $ipAddress, $pdo); header("Location: https://tildenic.org/?page=user_domains"); exit; } // Handle logout if (isset($_POST['logout'])) { session_destroy(); header("Location: https://tildenic.org/?page=login"); exit; } // Handle form submission if ($_SERVER["REQUEST_METHOD"] == "POST") { $domainId = $_POST['domain_id']; if (isset($_POST['update_ip'])) { // Update IP address $ipAddress = $_POST['ip_address']; updateDomainIP($domainId, $ipAddress, $pdo); } elseif (isset($_POST['remove_domain'])) { // Remove domain removeDomain($domainId, $pdo); } header("Location: https://tildenic.org/?page=user_domains"); exit; } $userId = getUserId($_SESSION['username'], $pdo); $domains = getUserDomains($userId, $pdo); ?> My Account

Your Domains