-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathedit.php
More file actions
28 lines (24 loc) · 1 KB
/
Copy pathedit.php
File metadata and controls
28 lines (24 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
include 'db.php';
$id = $_GET['id'];
if($_SERVER['REQUEST_METHOD'] === 'POST') {
$name = $_POST['student_name'];
$index = $_POST['student_index'];
$present = isset($_POST['present']) ? 1 : 0;
$stmt = $conn->prepare("UPDATE attendance SET student_name=?, student_index=?, present=? WHERE id=?");
$stmt->bind_param("ssii", $name, $index, $present, $id);
$stmt->execute();
header("Location: index.php");
exit;
}
$result = $conn->query("SELECT * FROM attendance WHERE id=$id");
$row = $result->fetch_assoc();
?>
<h1>Edytuj studenta</h1>
<form method="post">
Imię i nazwisko: <input type="text" name="student_name" value="<?= $row['student_name'] ?>" required><br>
Index: <input type="text" name="student_index" value="<?= $row['student_index'] ?>" required><br>
Obecność: <input type="checkbox" name="present" <?= $row['present'] ? 'checked' : '' ?>><br>
<input type="submit" value="Zapisz">
</form>
<a href="index.php">Powrót do listy</a>