redirectToLogin('Session expired. Please log in again.'); }
$userId = $user['id'];
$memberRef = 'RR' . str_pad($userId, 7, '0', STR_PAD_LEFT);
$refLink = 'https://relevantreflex.com/signup.php?mref=' . $memberRef;
try { $db = new Database(); $pdo = $db->getConnection(); } catch (Exception $e) { die('System error.'); }
// Points balance
$userPoints = ['points' => 0, 'total_earned' => 0, 'total_redeemed' => 0];
try {
$stmt = $pdo->prepare("SELECT points, total_earned, total_redeemed FROM user_points WHERE user_id = ?");
$stmt->execute([$userId]);
$p = $stmt->fetch();
if ($p) $userPoints = $p;
} catch (Exception $e) {}
// Referral stats & history
$stats = ['total_clicks' => 0, 'total_signups' => 0, 'total_verified' => 0, 'total_earned' => 0];
$referrals = [];
try {
$s = $pdo->prepare("
SELECT
COUNT(*) AS total_clicks,
SUM(signup_completed) AS total_signups,
SUM(email_verified) AS total_verified,
SUM(CASE WHEN signup_reward_paid = 1 THEN 5 ELSE 0 END) + SUM(survey_commission_earned) AS total_earned
FROM member_referral_clicks
WHERE referrer_user_id = ?
");
$s->execute([$userId]);
$row = $s->fetch();
if ($row) {
$stats['total_clicks'] = (int)$row['total_clicks'];
$stats['total_signups'] = (int)$row['total_signups'];
$stats['total_verified'] = (int)$row['total_verified'];
$stats['total_earned'] = round((float)$row['total_earned'], 2);
}
$h = $pdo->prepare("
SELECT id, ip_address, email, signup_completed, email_verified,
signup_reward_paid, survey_commission_earned, clicked_at, signed_up_at, verified_at
FROM member_referral_clicks
WHERE referrer_user_id = ?
ORDER BY clicked_at DESC
LIMIT 100
");
$h->execute([$userId]);
$referrals = $h->fetchAll();
} catch (Exception $e) {}
// Referral reward transactions
$rewardHistory = [];
try {
$stmt = $pdo->prepare("
SELECT transaction_type, points, source, description, created_at
FROM point_transactions
WHERE user_id = ? AND source IN ('member_referral', 'member_referral_survey')
ORDER BY created_at DESC LIMIT 50
");
$stmt->execute([$userId]);
$rewardHistory = $stmt->fetchAll();
} catch (Exception $e) {}
// Sidebar data
$profilerSections = ['personal_background'=>'Personal Background','household_family'=>'Household & Family','shopping_lifestyle'=>'Shopping & Lifestyle','technology_digital'=>'Technology & Digital','travel_transportation'=>'Travel & Transportation','health_fitness'=>'Health & Fitness','entertainment_media'=>'Entertainment & Media','food_dining'=>'Food & Dining','financial_services'=>'Financial Services','communication_payments'=>'Communication & Payments','household_classification'=>'Household Classification (ISEC)'];
$profilerCompletion = [];
try { $stmt = $pdo->prepare("SELECT section, is_completed FROM profiler_completion WHERE user_id = ?"); $stmt->execute([$userId]); while ($r = $stmt->fetch()) $profilerCompletion[$r['section']] = $r; } catch (Exception $e) {}
$completedSections = count(array_filter($profilerCompletion, fn($r) => $r['is_completed']));
$firstName = htmlspecialchars($user['first_name'] ?? explode('@', $user['email'])[0]);
$initials = strtoupper(substr($user['first_name'] ?? $user['email'], 0, 1) . substr($user['last_name'] ?? '', 0, 1));
if (strlen($initials) < 2) $initials = strtoupper(substr($user['email'], 0, 2));
function maskEmail($email) {
if (empty($email)) return '—';
$parts = explode('@', $email);
if (count($parts) !== 2) return '—';
$name = $parts[0];
$domain = $parts[1];
$masked = substr($name, 0, 1) . str_repeat('*', max(1, strlen($name) - 1));
$dparts = explode('.', $domain);
$maskedDomain = substr($dparts[0], 0, 1) . str_repeat('*', max(1, strlen($dparts[0]) - 1));
return $masked . '@' . $maskedDomain . '.' . ($dparts[1] ?? 'com');
}
?>
Referral Programme — Relevant Reflex
Your Referral Link
Share this link with anyone. When they register and verify their email, you earn rewards automatically.
Copy
Link copied to clipboard!
How It Works
🔗
Share your link with friends, groups, or on social media
✍️
They register using your link and verify their email
You earn ₹5 (10 pts)
📋
Every time they complete a survey
You earn ₹5 (10 pts) more
💰
Rewards go directly into your points balance for redemption
Where to Share Your Link
💬 Messaging Apps: WhatsApp groups, Telegram channels & groups, Instagram DMs
📱 Social Media: Facebook posts & stories, Instagram Reels/Shorts, YouTube video descriptions, Twitter/X threads
📣 Promotions: Digital ad banners, blog articles, email newsletters, LinkedIn posts
⚠️ Fair Use: Referral rewards are for genuine referrals only. Multiple clicks from the same IP are limited. Self-referrals are not counted. Abuse may result in reward reversal.
Click & Signup History
Reward Transactions
Click & Signup History
# Referred Email Clicked Signed Up Verified Signup Reward Survey Earnings
🔗
No referral clicks yet. Share your link to get started!
$r): ?>
Not signed up
✓ Yes
Pending
✓ Verified
⏳ Pending
—
₹5 Paid
Processing
—
0): ?>
₹
₹0.00
Referral Reward Transactions
Date Type Points Description
💰
No referral rewards yet. Start sharing your link!
Signup Reward
Survey Reward
+ pts
₹