-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheditUser.php
More file actions
71 lines (61 loc) · 2.22 KB
/
Copy patheditUser.php
File metadata and controls
71 lines (61 loc) · 2.22 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
<?php
/**
* File: editUser.php
* Description: Form to edit existing user details via Admin Dashboard.
*/
session_start();
require_once 'DBConn.php';
if (!isset($_SESSION['adminLoggedIn'])) {
header('Location: adminLogin.php');
exit();
}
if (isset($_GET['id'])) {
$id = mysqli_real_escape_string($conn, $_GET['id']);
$query = "SELECT * FROM tblUser WHERE userID = $id";
$result = mysqli_query($conn, $query);
if (mysqli_num_rows($result) == 1) {
$user = mysqli_fetch_assoc($result);
} else {
die("User not found.");
}
} else {
header('Location: adminDashboard.php');
exit();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Edit User | Pastimes Admin</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<nav>
<a href="eshop.php"><strong>PASTIMES</strong></a>
<a href="adminDashboard.php">Back to Dashboard</a>
</nav>
<div class="card">
<h2>Edit User Details</h2>
<p>Updating profile for ID: #<?php echo $user['userID']; ?></p>
<hr><br>
<form action="adminDashboard.php" method="POST" class="modern-form">
<input type="hidden" name="userID" value="<?php echo $user['userID']; ?>">
<div class="field">
<label>First Name</label>
<input type="text" name="firstName" value="<?php echo htmlspecialchars($user['firstName']); ?>" required>
</div>
<div class="field">
<label>Last Name</label>
<input type="text" name="lastName" value="<?php echo htmlspecialchars($user['lastName']); ?>" required>
</div>
<div class="field">
<label>Email Address</label>
<input type="email" name="userEmail" value="<?php echo htmlspecialchars($user['email']); ?>" required>
</div>
<button type="submit" name="btnUpdate" class="btn-black-long">Save Changes</button>
<a href="adminDashboard.php" style="display: block; text-align: center; margin-top: 15px; color: #666; text-decoration: none;">Cancel</a>
</form>
</div>
</body>
</html>