prepare(" SELECT id, company_name, email, status, account_status FROM affiliates WHERE LOWER(email) = LOWER(?) "); $stmt->execute([$email]); $affiliate = $stmt->fetch(); // Always show success to prevent email enumeration if ($affiliate && $affiliate['status'] === 'active' && $affiliate['account_status'] !== 'suspended') { // Invalidate existing unused tokens $pdo->prepare(" UPDATE partner_password_resets SET used = 1 WHERE affiliate_id = ? AND used = 0 ")->execute([$affiliate['id']]); $token = generatePartnerToken(); $expires = date('Y-m-d H:i:s', strtotime('+2 hours')); $pdo->prepare(" INSERT INTO partner_password_resets (affiliate_id, email, token, expires_at) VALUES (?, ?, ?, ?) ")->execute([$affiliate['id'], $affiliate['email'], $token, $expires]); $resetLink = 'https://relevantreflex.com/partners/reset-password.php?token=' . $token; $name = htmlspecialchars($affiliate['company_name']); $emailBody = "

Relevant Reflex — Partner Portal

Dear {$name},

We received a request to reset the password for your partner portal account. Click the button below to set a new password:

Reset My Password

Or copy this link into your browser:
{$resetLink}

⏱ This link expires in 2 hours. If you did not request this, you can safely ignore this email.

© " . date('Y') . " Relevant Reflex. All rights reserved.
Need help? partners@relevantreflex.com

"; sendPartnerEmail($affiliate['email'], 'Reset Your Partner Portal Password — Relevant Reflex', $emailBody); logPartnerActivity('Password reset requested', ['affiliate_id' => $affiliate['id'], 'email' => $affiliate['email']]); } $success = true; } catch (Exception $e) { logPartnerActivity('Forgot password error', ['error' => $e->getMessage()]); $errors[] = 'An error occurred. Please try again.'; } } } ?> Forgot Password — Relevant Reflex Partner Portal

Check Your Email

If that email is registered, a password reset link has been sent. Please check your inbox (and spam folder).

The link expires in 2 hours.

🔒

Forgot Your Password?

Enter your registered partner email address and we'll send you a link to reset your password.

'; ?>