-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathedit.php
More file actions
24 lines (20 loc) · 772 Bytes
/
edit.php
File metadata and controls
24 lines (20 loc) · 772 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
include "db.php";
$id = $_GET['id'];
$data = $conn->query("SELECT * FROM students WHERE id=$id")->fetch_assoc();
if ($_SERVER['REQUEST_METHOD'] == "POST") {
$name = $_POST['name'];
$class = $_POST['class'];
$phone = $_POST['phone'];
$sql = "UPDATE students SET name='$name', class='$class', phone='$phone' WHERE id=$id";
$conn->query($sql);
header("Location: index.php");
}
?>
<h2>Edit Student</h2>
<form method="post">
Name: <input type="text" name="name" value="<?= $data['name'] ?>"><br><br>
Class: <input type="text" name="class" value="<?= $data['class'] ?>"><br><br>
Phone: <input type="text" name="phone" value="<?= $data['phone'] ?>"><br><br>
<button type="submit">Update</button>
</form>