prepare(" SELECT pr.*, a.id as affiliate_id, a.email, a.company_name, a.is_password_set FROM partner_password_resets pr JOIN affiliates a ON pr.affiliate_id = a.id WHERE pr.token = ? AND pr.expires_at > NOW() AND pr.used = 0 "); $stmt->execute([$token]); $tokenData = $stmt->fetch(); if ($tokenData) { $validToken = true; $affiliate = $tokenData; } else { $errors[] = 'Invalid or expired password setup link. Please request a new link.'; } } catch (Exception $e) { $errors[] = 'An error occurred. Please try again.'; logPartnerActivity('Token verification error', ['error' => $e->getMessage()]); } } // Handle password setup if ($_SERVER['REQUEST_METHOD'] === 'POST' && $validToken) { $password = isset($_POST['password']) ? $_POST['password'] : ''; $confirmPassword = isset($_POST['confirm_password']) ? $_POST['confirm_password'] : ''; if (empty($password)) { $errors[] = 'Please enter a password.'; } elseif (strlen($password) < 8) { $errors[] = 'Password must be at least 8 characters long.'; } elseif ($password !== $confirmPassword) { $errors[] = 'Passwords do not match.'; } elseif (!preg_match('/[A-Z]/', $password)) { $errors[] = 'Password must contain at least one uppercase letter.'; } elseif (!preg_match('/[a-z]/', $password)) { $errors[] = 'Password must contain at least one lowercase letter.'; } elseif (!preg_match('/[0-9]/', $password)) { $errors[] = 'Password must contain at least one number.'; } else { try { $pdo->beginTransaction(); // Hash password $passwordHash = password_hash($password, PASSWORD_DEFAULT); // Update affiliate with password $stmt = $pdo->prepare(" UPDATE affiliates SET password_hash = ?, is_password_set = 1, account_status = 'active' WHERE id = ? "); $stmt->execute([$passwordHash, $affiliate['affiliate_id']]); // Mark token as used $stmt = $pdo->prepare("UPDATE partner_password_resets SET used = 1 WHERE token = ?"); $stmt->execute([$token]); $pdo->commit(); $success = true; logPartnerActivity('Password set successfully', [ 'affiliate_id' => $affiliate['affiliate_id'], 'email' => $affiliate['email'] ]); } catch (Exception $e) { $pdo->rollBack(); $errors[] = 'An error occurred while setting your password. Please try again.'; logPartnerActivity('Password setup error', [ 'affiliate_id' => $affiliate['affiliate_id'], 'error' => $e->getMessage() ]); } } } ?> Set Your Password - Partner Portal

Password Set Successfully!

Your partner account is now active. You can login using your email and password.

Go to Login
Invalid or Expired Link

This password setup link is invalid or has expired. Please request a new link from the login page.

Back to Login

Set Your Password

Welcome, ! Please create a strong password for your partner account.

Password Requirements:
  • At least 8 characters long
  • Contains at least one uppercase letter (A-Z)
  • Contains at least one lowercase letter (a-z)
  • Contains at least one number (0-9)

Your password is encrypted and secure