prepare("SELECT id FROM users WHERE email = ?"); $stmt->execute([$email]); if ($stmt->fetch()) { $errors[] = 'An account with this email already exists.'; } else { $hashed_password = password_hash($password, PASSWORD_DEFAULT); $stmt = $pdo->prepare("INSERT INTO users (name, email, password) VALUES (?, ?, ?)"); $stmt->execute([$name, $email, $hashed_password]); // Send welcome email $subject = "Welcome to AI Web App Generator!"; $htmlBody = "
Thank you for registering. You can now log in and start creating your web application.
"; $textBody = "Welcome, {$name}! Thank you for registering. You can now log in and start creating your web application."; MailService::sendMail($email, $subject, $htmlBody, $textBody); $success = 'Registration successful! You can now log in.'; } } catch (PDOException $e) { $errors[] = "Database error: " . $e->getMessage(); } } } $pageTitle = "Register"; include 'partials/header.php'; ?>