Manage Teachers
Create a New Teacher
Existing Teachers
No teachers have been created yet. Use the form above to add the first one.
-
Created:
prepare("INSERT INTO teachers (name, email) VALUES (?, ?)"); if ($stmt->execute([$teacherName, $teacherEmail])) { $message = 'Teacher "' . htmlspecialchars($teacherName) . '" created successfully!'; } else { $error = 'Failed to create teacher.'; } } catch (PDOException $e) { if ($e->errorInfo[1] == 1062) { // Duplicate entry $error = 'Error: A teacher with the email "' . htmlspecialchars($teacherEmail) . '" already exists.'; } else { $error = 'Database error: ' . $e->getMessage(); } } } } // Fetch all teachers to display $teachers = []; try { $pdo = db(); $stmt = $pdo->query("SELECT id, name, email, created_at FROM teachers ORDER BY created_at DESC"); $teachers = $stmt->fetchAll(PDO::FETCH_ASSOC); } catch (PDOException $e) { $error = 'Database error: ' . $e->getMessage(); } ?>
No teachers have been created yet. Use the form above to add the first one.