prepare(" SELECT * FROM clients WHERE LOWER(email) = LOWER(?) AND (password IS NULL OR password = '') "); $stmt->execute([$email]); $client = $stmt->fetch(); if ($client) { $token = bin2hex(random_bytes(32)); $expires = date('Y-m-d H:i:s', strtotime('+24 hours')); $stmt = $pdo->prepare(" INSERT INTO password_reset_tokens (client_id, email, token, expires_at) VALUES (?, ?, ?, ?) ON DUPLICATE KEY UPDATE token = ?, expires_at = ? "); $stmt->execute([$client['id'], $email, $token, $expires, $token, $expires]); $setupLink = SITE_URL . '/clients/setup-password.php?token=' . $token; $emailMessage = "

Welcome to Relevant Reflex Client Portal

Dear {$client['company_name']},

Please set your password by clicking the button below:

Set Password

Or copy this link: {$setupLink}

Link expires in 24 hours.

"; if (sendClientEmail($email, 'Set Your Password - Relevant Reflex', $emailMessage)) { $success_message = 'Password setup link sent to your email!'; } else { $errors[] = 'Failed to send email. Contact support.'; } } else { $errors[] = 'Email not found or account already activated.'; } } catch (Exception $e) { $errors[] = 'An error occurred. Please try again.'; logClientActivity('Email verification error', ['email' => $email, 'error' => $e->getMessage()]); } } } // Handle login if (isset($_POST['action']) && $_POST['action'] === 'login') { $email = isset($_POST['email']) ? trim($_POST['email']) : ''; $password = isset($_POST['password']) ? $_POST['password'] : ''; if (empty($email) || empty($password)) { $errors[] = 'Please enter both email and password.'; } else { $result = clientLogin($email, $password); if ($result['success']) { header('Location: /clients/client-dashboard.php'); exit; } else { $errors[] = $result['message']; } } } ?> Client Login - Relevant Reflex
📊

Project Management Module

Access your portal to create and manage your online survey projects, track responses, download reports, and collaborate with our team efficiently.

Welcome Back!

⚠️
Login
First Time?

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

Use the same email you provided to Relevant Reflex
Need help? Contact Support