prepare(" SELECT id, email, company_name, is_password_set, account_status FROM affiliates WHERE email = ? AND status = 'active' "); $stmt->execute([$email]); $affiliate = $stmt->fetch(); if (!$affiliate) { $errors[] = 'Email not found in our partner records. Please contact support.'; } elseif ($affiliate['account_status'] === 'suspended') { $errors[] = 'Your account has been suspended. Please contact support.'; } elseif ($affiliate['is_password_set']) { $info_message = 'Your password is already set. Please use the login form below.'; } else { // Generate password setup token $token = generatePartnerToken(); $expires = date('Y-m-d H:i:s', strtotime('+24 hours')); // Save token $stmt = $pdo->prepare(" INSERT INTO partner_password_resets (affiliate_id, email, token, expires_at) VALUES (?, ?, ?, ?) "); $stmt->execute([$affiliate['id'], $email, $token, $expires]); // Update account status to active if pending if ($affiliate['account_status'] === 'pending') { $stmt = $pdo->prepare("UPDATE affiliates SET account_status = 'active' WHERE id = ?"); $stmt->execute([$affiliate['id']]); } // Send email with password setup link $setupLink = SITE_URL . '/partners/setup-password.php?token=' . $token; $emailSubject = 'Set Your Partner Portal Password - Relevant Reflex'; $emailMessage = "

Welcome to Relevant Reflex Partner Portal

Dear {$affiliate['company_name']},

Welcome to the Relevant Reflex Partner Portal! We're excited to have you as our partner.

To access your partner dashboard, please set your password by clicking the button below:

Set My Password

Or copy and paste this link into your browser:

{$setupLink}

This link will expire in 24 hours.

Once you set your password, you'll be able to:

If you didn't request this, please contact our support team immediately.

"; if (sendPartnerEmail($email, $emailSubject, $emailMessage)) { $success_message = 'Password setup link has been sent to your email. Please check your inbox and follow the instructions.'; logPartnerActivity('Password setup link sent', ['email' => $email, 'affiliate_id' => $affiliate['id']]); } else { $errors[] = 'Failed to send email. Please try again or contact support.'; logPartnerActivity('Failed to send password setup email', ['email' => $email]); } } } catch (Exception $e) { $errors[] = 'An error occurred. Please try again.'; logPartnerActivity('Email verification error', ['email' => $email, 'error' => $e->getMessage()]); } } } // Handle login if (isset($_POST['action']) && $_POST['action'] === 'login') { $email = isset($_POST['email']) ? trim(strtolower($_POST['email'])) : ''; $password = isset($_POST['password']) ? $_POST['password'] : ''; $rememberMe = isset($_POST['remember_me']); if (empty($email)) { $errors[] = 'Please enter your email address.'; } elseif (empty($password)) { $errors[] = 'Please enter your password.'; } else { $sessionManager = getPartnerSessionManager(); $result = $sessionManager->login($email, $password, $rememberMe); if ($result['success']) { header('Location: /partners/partner-dashboard.php'); exit; } else { $errors[] = $result['message']; } } } ?> Partner Login - Relevant Reflex

Partner Portal

Access your partner dashboard, track referrals, manage commissions, and grow together with us.

Welcome Back!

Login
First Time?

Enter the email address you provided during partner onboarding. We'll send you a link to set your password.

Use the same email you provided to Relevant Reflex