Wallos: Open-source, self-hostable personal subscription tracker. Visualize your recurring expenses, manage your budget, and save money.
<?php
$currentPage = basename($_SERVER['PHP_SELF']);
if ($currentPage == 'index.php') {
// Redirect to subscriptions page if no subscriptions exist
$stmt = $db->prepare("SELECT COUNT(*) FROM subscriptions WHERE user_id = :userId");
$stmt->bindValue(':userId', $userId, SQLITE3_INTEGER);
$result = $stmt->execute();
$row = $result->fetchArray(SQLITE3_NUM);
$subscriptionCount = $row[0];
if ($subscriptionCount === 0) {
header('Location: subscriptions.php');
exit;
}
}