-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprofile.php
172 lines (135 loc) · 6.5 KB
/
profile.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
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<?php
session_start();
include 'dbconnect.php';
if (!isset($_SESSION['user_id'])) {
header("Location: login.php");
exit();
}
$user_id = $_SESSION['user_id'];
$sql = "SELECT * FROM users WHERE id = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("i", $user_id);
$stmt->execute();
$result = $stmt->get_result();
$user = $result->fetch_assoc();
$role = $_SESSION['role'];
$stmt->close();
$conn->close();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>User Profile</title>
<!-- SB Admin 2 Bootstrap CSS -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/startbootstrap-sb-admin-2/4.0.0/css/sb-admin-2.min.css" rel="stylesheet">
<!-- Font Awesome -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css" rel="stylesheet">
</head>
<body id="page-top">
<div id="wrapper">
<!-- Sidebar -->
<ul class="navbar-nav bg-gradient-primary sidebar sidebar-dark accordion" id="accordionSidebar">
<a class="sidebar-brand d-flex align-items-center justify-content-center" href="dashboard.php">
<div class="sidebar-brand-text mx-3">SERVPRO</div>
</a>
<hr class="sidebar-divider my-0">
<!-- Nav Item - Dashboard -->
<li class="nav-item">
<a class="nav-link" href="dashboard.php">
<i class="fas fa-fw fa-tachometer-alt"></i>
<span>Dashboard</span></a>
</li>
<hr class="sidebar-divider">
<!-- Nav Item - Inventory -->
<li class="nav-item">
<a class="nav-link" href="inventory.php">
<i class="fas fa-fw fa-box"></i>
<span>Inventory</span></a>
</li>
<!-- Nav Item - Withdraw -->
<li class="nav-item">
<a class="nav-link" href="withdraw.php">
<i class="fas fa-fw fa-sign-out-alt"></i>
<span> Inventory Withdrawal</span></a>
</li>
<!-- Nav Item - Status -->
<li class="nav-item">
<a class="nav-link" href="toolstatus.php">
<i class="fas fa-fw fa-ellipsis-h"></i>
<span>Status</span></a>
</li>
<?php if ($role === 'admin'): ?>
<!-- Nav Item - Users -->
<li class="nav-item">
<a class="nav-link" href="users.php">
<i class="fas fa-fw fa-user-circle"></i>
<span>Users</span></a>
</li>
<?php endif; ?>
<!-- Nav Item - History -->
<li class="nav-item">
<a class="nav-link" href="history.php">
<i class="fas fa-fw fa-history"></i>
<span>History</span></a>
</li>
<!-- Divider -->
<hr class="sidebar-divider d-none d-md-block">
</ul>
<!-- End of Sidebar -->
<div id="content-wrapper" class="d-flex flex-column">
<!-- Main Content -->
<div id="content">
<nav class="navbar navbar-expand navbar-light bg-white topbar mb-4 static-top shadow">
<button id="sidebarToggleTop" class="btn btn-link d-md-none rounded-circle mr-3">
<i class="fa fa-bars"></i>
</button>
</nav>
<div class="container-fluid">
<h1 class="h3 mb-4 text-gray-800">User Profile</h1>
<div class="row">
<div class="col-lg-8">
<!-- User Details Card -->
<div class="card shadow mb-4">
<div class="card-header py-3">
<h6 class="m-0 font-weight-bold text-primary">Your Information</h6>
</div>
<div class="card-body">
<form id="profileForm" method="POST" action="update_profile.php" enctype="multipart/form-data">
<div class="form-group">
<label for="username">Username</label>
<input type="text" class="form-control" id="username" name="username" value="<?php echo htmlspecialchars($user['username']); ?>" required>
</div>
<div class="form-group">
<label for="role">Role</label>
<input type="text" class="form-control" id="role" name="role" value="<?php echo htmlspecialchars($user['role']); ?>" readonly>
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" class="form-control" id="password" name="password" placeholder="Leave blank to keep current password">
</div>
<div class="form-group">
<label for="image">Profile Image</label>
<input type="file" class="form-control-file" id="image" name="image">
</div>
<button type="submit" class="btn btn-primary">Update Profile</button>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- End of Main Content -->
</div>
</div>
<!-- Bootstrap core JavaScript-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/4.5.2/js/bootstrap.bundle.min.js"></script>
<!-- Core plugin JavaScript-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.4.1/jquery.easing.min.js"></script>
<!-- Custom scripts for all pages-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/startbootstrap-sb-admin-2/4.0.0/js/sb-admin-2.min.js"></script>
</body>
</html>