-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathedit_user.php
More file actions
64 lines (49 loc) · 1.79 KB
/
Copy pathedit_user.php
File metadata and controls
64 lines (49 loc) · 1.79 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="edit.css">
<title>User</title>
</head>
<body>
<h1>User Update</h1>
<?php
require("connector.php");
if (isset($_GET['id'])) {
$user_id = $_GET['id'];
$db = new DBConnection;
$user = $db->getUserById($user_id);
if ($user) {
$user_name = $user['user_name'];
$email = $user['email'];
$password = $user['password'];
$role = $user['role'];
} else {
header("Location: homepage.php");
exit;
}
} else {
header("Location: homepage.php");
exit;
}
?>
<form action="process_edit_user.php" method="post">
<input type="hidden" name="user_id" value="<?php echo $user_id; ?>">
<label for="user_name">Username:</label><br>
<input type="text" id="user_name" name="user_name" value="<?php echo $user_name; ?>"><br>
<label for="email">Email:</label><br>
<input type="text" id="email" name="email" value="<?php echo $email; ?>"><br>
<label for="password">Password:</label><br>
<input type="text" id="password" name="password" value="<?php echo $password; ?>"><br>
<label for="role">Role:</label><br>
<select id="role" name="role">
<option value="admin" <?php if ($role == 'admin') echo 'selected'; ?>>Admin</option>
<option value="-" <?php if ($role == '-') echo '-'; ?>>-----</option>
</select>
<br><br>
<input type="submit" value="Update User">
<a href="index.php">Back</a>
</form>
</body>
</html>