2100) { $error = "Invalid graduation year."; } else { // Check if email already exists $stmt = db()->prepare("SELECT id FROM users WHERE email = ?"); $stmt->execute([$email]); if ($stmt->fetch()) { $error = "Email already registered."; } else { // Generate verification code $verification_code = bin2hex(random_bytes(16)); $hashed_password = password_hash($password, PASSWORD_DEFAULT); // Insert user $stmt = db()->prepare("INSERT INTO users (full_name, email, password, role, university, graduation_year, verification_code, verified) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"); try { // Investors are verified by default as they don't need student verification $is_verified = ($role === 'investor') ? 1 : 0; $stmt->execute([$full_name, $email, $hashed_password, $role, $university, $graduation_year, $verification_code, $is_verified]); if ($role === 'founder') { $success = "Registration successful! A verification link has been sent to $email. Please verify your account before logging in."; // Send verification email $baseUrl = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://" . $_SERVER['HTTP_HOST']; $verifyUrl = "$baseUrl/verify.php?code=$verification_code"; $subject = "Verify your " . PLATFORM_NAME . " account"; $html = "
Please click the link below to verify your student status:
"; $text = "Welcome to " . PLATFORM_NAME . "!\n\nPlease visit the following URL to verify your account:\n$verifyUrl"; MailService::sendMail($email, $subject, $html, $text); } else { $success = "Registration successful! You can now log in to your investor account."; } } catch (PDOException $e) { $error = "Database error: " . $e->getMessage(); } } } } $platformName = defined('PLATFORM_NAME') ? PLATFORM_NAME : 'Gatsby'; ?>Verify your student or graduate status to get started.