prepare('SELECT id FROM users WHERE email = ?'); $stmt->execute([$email]); if ($stmt->fetch()) { $error = 'An account with this email already exists.'; } else { $hashed_password = password_hash($password, PASSWORD_DEFAULT); $token = bin2hex(random_bytes(32)); $stmt = $db->prepare('INSERT INTO users (name, email, password, is_verified, verification_token) VALUES (?, ?, ?, 0, ?)'); if ($stmt->execute([$name, $email, $hashed_password, $token])) { // Send verification email $proto = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') ? 'https' : 'http'; $host = $_SERVER['HTTP_HOST'] ?? 'localhost'; $verify_link = "$proto://$host/verify.php?token=$token"; $subject = "Verify your account - $project_name"; $html = "

Welcome, " . htmlspecialchars($name) . "!

Thank you for signing up for $project_name. Please click the button below to verify your email address and activate your account:

Verify Email Address

If the button doesn't work, copy and paste this link into your browser:

$verify_link

Best regards,
The $project_name Team

"; $text = "Welcome, $name!\n\nPlease verify your email address by clicking this link: $verify_link\n\nBest regards,\nThe $project_name Team"; $res = MailService::sendMail($email, $subject, $html, $text); if (!empty($res['success'])) { $success = 'Account created successfully! Please check your email to verify your account.'; } else { $success = 'Account created, but we failed to send the verification email. Please contact support.'; error_log('Verification email failed: ' . ($res['error'] ?? 'unknown error')); } } else { $error = 'Failed to create account. Please try again.'; } } } } ?> Sign Up — <?php echo htmlspecialchars($project_name); ?>

Create an account

Start your finance journey with us today.

Success!


Go to Login

Already have an account? Sign In