exec("CREATE TABLE IF NOT EXISTS students ( id INT AUTO_INCREMENT PRIMARY KEY, first_name VARCHAR(100) NOT NULL, last_name VARCHAR(100) NOT NULL, date_of_birth DATE NOT NULL, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP );"); if ($_SERVER["REQUEST_METHOD"] == "POST") { $first_name = trim($_POST['first_name']); $last_name = trim($_POST['last_name']); $date_of_birth = trim($_POST['date_of_birth']); if (empty($first_name) || empty($last_name) || empty($date_of_birth)) { $notification = ["type" => "danger", "message" => "All fields are required."]; } else { $stmt = $pdo->prepare("INSERT INTO students (first_name, last_name, date_of_birth) VALUES (?, ?, ?)"); if ($stmt->execute([$first_name, $last_name, $date_of_birth])) { $notification = ["type" => "success", "message" => "Student added successfully!"]; } else { $notification = ["type" => "danger", "message" => "Error: Could not add student."]; } } } } catch (Exception $e) { $notification = ["type" => "danger", "message" => "Database error: " . $e->getMessage()]; error_log("DB Error: " . $e->getMessage()); } ?> <?= htmlspecialchars($page_title) ?> - <?= htmlspecialchars($_SERVER['PROJECT_NAME'] ?? 'WebApp') ?>

New Student Admission

Please enter a first name.
Please enter a last name.
Please enter a valid date of birth.