User Tools

Site Tools


attendance

This is an old revision of the document!


(If the iframe fails to load: https://nerdcruft.net/mlug/)

<?php === CONFIG === $attendanceDir = DOKU_INC . 'data/attendance/'; if (!is_dir($attendanceDir)) { mkdir($attendanceDir, 0755, true); } File name based on current month (e.g. attendance_2026_01.txt) $monthKey = date('Y_m'); $file = $attendanceDir . “attendance_$monthKey.txt”;

Handle form submission if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['attendee'])) { $name = trim(strip_tags($_POST['attendee'])); if ($name !== '') { file_put_contents($file, $name . PHP_EOL, FILE_APPEND | LOCK_EX); } } Load existing attendance $attendees = []; if (file_exists($file)) {

  $attendees = file($file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);

} ?>

<form method=“post”>

  <input type="text" name="attendee" placeholder="Enter name" required>
  <button type="submit">Add</button>

</form>

<?php if (!empty($attendees)): ?>

  <h3>Attendance (<?php echo date('F Y'); ?>)</h3>
  <ul>
      <?php foreach ($attendees as $person): ?>
          <li><?php echo htmlspecialchars($person); ?></li>
      <?php endforeach; ?>
  </ul>

<?php else: ?>

  <p>No attendance recorded yet this month.</p>

<?php endif; ?>

attendance.1768469116.txt.gz · Last modified: 2026/01/15 09:25 by admin