exec('CREATE TABLE IF NOT EXISTS urls (id INTEGER PRIMARY KEY AUTOINCREMENT, long_url TEXT, short_code TEXT UNIQUE, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP)'); // Handle URL shortening if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['long_url'])) { $longUrl = $_POST['long_url']; $shortCode = generateShortCode(); // Validate URL if (!filter_var($longUrl, FILTER_VALIDATE_URL)) { $error = "Invalid URL format"; } else { $stmt = $db->prepare('INSERT INTO urls (long_url, short_code) VALUES (:long_url, :short_code)'); $stmt->bindValue(':long_url', $longUrl, SQLITE3_TEXT); $stmt->bindValue(':short_code', $shortCode, SQLITE3_TEXT); if ($stmt->execute()) { $success = "Short URL created: " . getBaseUrl() . $shortCode; } else { $error = "Error creating short URL";...