User Tools

Site Tools


testphp

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

testphp [2026/01/15 09:26] – created admintestphp [2026/01/15 09:27] (current) – removed admin
Line 1: Line 1:
-<?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; ?> 
  
testphp.1768469178.txt.gz · Last modified: 2026/01/15 09:26 by admin