prepare("SELECT id FROM users WHERE email = ? LIMIT 1"); $stmt->execute([$email]); $user = $stmt->fetch(); if ($user) { $token = bin2hex(random_bytes(32)); $expires = date('Y-m-d H:i:s', strtotime('+1 hour')); $stmt = db()->prepare("INSERT INTO password_resets (email, token, expires_at) VALUES (?, ?, ?)"); $stmt->execute([$email, $token, $expires]); // Send Email $resetLink = (isset($_SERVER['HTTPS']) ? "https" : "http") . "://$_SERVER[HTTP_HOST]/reset_password.php?token=$token"; $subject = "Password Reset Request"; $html = "
We received a request to reset your password for SR&ED Manager.
Click the link below to set a new password. This link will expire in 1 hour.
If you did not request this, please ignore this email.
"; $text = "Reset your password by clicking this link: $resetLink"; MailService::sendMail($email, $subject, $html, $text); } // Always show success to prevent email enumeration $success = true; } ?>Enter your email to receive a reset link