-
Notifications
You must be signed in to change notification settings - Fork 0
/
process_update.php
31 lines (26 loc) · 1.06 KB
/
process_update.php
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
29
30
31
<?php
// This code is used to update student details in edit_studnet.php
include 'database.php';
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$matric_id = $_POST['matric_id'];
$full_name = $_POST['fullName'];
$gender = $_POST['gender'];
$ic_number = $_POST['icNumber'];
$school = $_POST['school'];
// Handle file upload
$image = $_FILES['image']['name'];
$target = "images/" . basename($image);
if (move_uploaded_file($_FILES['image']['tmp_name'], $target)) {
$sql = "UPDATE student SET full_name='$full_name', gender='$gender', ic_number='$ic_number', school='$school', image='$image' WHERE matric_id='$matric_id'";
} else {
$sql = "UPDATE student SET full_name='$full_name', gender='$gender', ic_number='$ic_number', school='$school' WHERE matric_id='$matric_id'";
}
if ($conn->query($sql) === TRUE) {
echo "Record updated successfully";
header('Location: manage.php');
} else {
echo "Error updating record: " . $conn->error;
}
$conn->close();
}
?>