-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathedit_member.php
More file actions
151 lines (128 loc) · 3.92 KB
/
Copy pathedit_member.php
File metadata and controls
151 lines (128 loc) · 3.92 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<?php
session_start();
include 'db_connection.php';
if (!isset($_SESSION['username'])) {
header("Location: login1.php"); // Agar login nahi hai toh wapas bhejo
exit();
}
if (!isset($_GET['id'])) {
die("Invalid Request!");
}
$student_id = $_GET['id'];
// Student details fetch karo
$query = "SELECT * FROM students WHERE student_id = ?";
$stmt = mysqli_prepare($conn, $query);
mysqli_stmt_bind_param($stmt, "i", $student_id);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
$student = mysqli_fetch_assoc($result);
if (!$student) {
die("Student not found!");
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$name = $_POST['name'];
$department = $_POST['department'];
// Update Query
$updateQuery = "UPDATE students SET name = ?, department = ? WHERE student_id = ?";
$updateStmt = mysqli_prepare($conn, $updateQuery);
mysqli_stmt_bind_param($updateStmt, "ssi", $name, $department, $student_id);
if (mysqli_stmt_execute($updateStmt)) {
$_SESSION['success_message'] = "Student details updated successfully!";
header("Location: view_members.php");
exit();
} else {
$_SESSION['error_message'] = "Failed to update student details!";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Edit Member</title>
<style>
body { font-family: Arial, sans-serif; text-align: center; }
form { width: 50%; margin: auto; padding: 20px; border: 1px solid #ccc; border-radius: 5px; }
label, input, select { display: block; width: 100%; margin-bottom: 10px; }
.submit-btn { background: #28a745; color: white; padding: 10px; border: none; cursor: pointer; }
.submit-btn:hover { background: #218838; }
body {
font-family: Arial, sans-serif;
text-align: center;
background-color: #f4f4f4;
margin: 0;
padding: 0;
}
.container {
width: 50%;
margin: 50px auto;
background: white;
padding: 20px;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
border-radius: 10px;
}
h2 {
color: #007bff;
margin-bottom: 20px;
}
label {
font-weight: bold;
display: block;
margin-top: 15px;
text-align: left;
}
input[type="text"] {
width: calc(100% - 20px);
padding: 10px;
margin-top: 5px;
border: 1px solid #ddd;
border-radius: 5px;
font-size: 16px;
display: block;
margin-bottom: 10px;
}
.submit-btn {
background-color: #007bff;
color: white;
padding: 10px 15px;
border: none;
cursor: pointer;
font-size: 16px;
border-radius: 5px;
width: 100%;
margin-top: 10px;
}
.submit-btn:hover {
background-color: #0056b3;
}
.back-btn {
display: inline-block;
margin-top: 15px;
padding: 10px 15px;
background-color: #dc3545;
color: white;
text-decoration: none;
border-radius: 5px;
}
.back-btn:hover {
background-color: #a71d2a;
}
</style>
</head>
<body>
<div class="container">
<h2>Edit Student Details</h2>
<form method="POST">
<label for="student_id">Student ID:</label>
<input type="text" name="student_id" value="<?= htmlspecialchars($student['student_id']) ?>" readonly>
<label for="name">Name:</label>
<input type="text" name="name" value="<?= htmlspecialchars($student['name']) ?>" required>
<label for="department">Department:</label>
<input type="text" name="department" value="<?= htmlspecialchars($student['department']) ?>" required>
<button type="submit" class="submit-btn">Update</button>
</form>
<a href="view_members.php" class="back-btn">⬅ Back to Members</a>
</div>
</body>
</html>