-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patheditAccount.php
More file actions
210 lines (188 loc) · 7.88 KB
/
Copy patheditAccount.php
File metadata and controls
210 lines (188 loc) · 7.88 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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<?php
/* Date Name Changes
* 10/27/2019 Andrey Coding page
* 10/28/2019 Dmitriy Code Cleanup
*
*
*
*/
session_start();//session is starting
//checking if loggedin session is set, and role is Manager, if not rederecting to main page
if (!isset($_SESSION["loggedin"]) || $_SESSION["loggedin"] !== true || !isset($_SESSION["role"]) || $_SESSION["role"] !== "HR") {
header("location: index.php");
exit;
}
$last_name = "";
$first_name = "";
$address = "";
$city = "";
$state = "";
$zip = "";
$email = "";
$role = "";
$user_name = "";
$user_firstName_err ="";
$user_lastName_err ="";
$user_address_err ="";
$user_city_err ="";
$user_zip_err ="";
$user_state_err ="";
$user_email_err ="";
if ($_GET) {
$u_id = $_GET['id'];
include_once("./includes/open_conn.inc");
$select_query = "SELECT lastName, firstName, address, city, state, zip, email FROM user_info WHERE user_id=" . $u_id;
$select_query2 = "SELECT username, role FROM users WHERE id=" . $u_id;
if ($result = mysqli_query($link, $select_query) AND $result2 = mysqli_query($link, $select_query2)) {
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_array($result)) {
$last_name = $row['lastName'];
$first_name = $row['firstName'];
$address = $row['address'];
$city = $row['city'];
$state = $row['state'];
$zip = $row['zip'];
$email = $row['email'];
}
mysqli_free_result($result);
} else {
//echo "No matching records are found.";
}
if (mysqli_num_rows($result2) > 0) {
while ($row2 = mysqli_fetch_array($result2)) {
$role = $row2['role'];
$user_name = $row2['username'];
}
mysqli_free_result($result2);
} else {
//echo "No matching records are found.";
}
} else {
echo "ERROR: Could not able to execute sql. "
. mysqli_error($link);
return false;
};
include_once("./includes/close_conn.inc");
}
?>
<?php include('wrapper/Header.php'); ?>
<title>Edit User Account</title>
</head>
<body>
<?php include('wrapper/Logo.php'); ?>
<div class="page-header">
<h1><b><?php echo htmlspecialchars($_SESSION["username"]); ?></b> please make needed changes.</h1>
</div> <br><br>
<div>
<form action="./php_scripts/editUsersInfoInDB.php" method="post">
<table align="center">
<tr>
<th>Field Name</th>
<th>Current Value</th>
<th>New Value</th>
</tr>
<tr>
<th>id</th>
<td><?php echo $u_id; ?></td>
<td><input type="hidden" name="editing_user_id" value="<?php echo $u_id; ?>"></td>
</tr>
<tr>
<th>username</th>
<td><?php echo $user_name; ?></td>
</tr>
<tr>
<th><label>Role</label></th>
<td><?php echo $role; ?></td>
<td>
<div class="form-group">
<select name="role" size="1">
<option value="HR">HR</option>
<option value="Manager">Manager</option>
<option value="Trainee">Trainee</option>
</select>
</div>
</td>
</tr>
<tr>
<th>First Name</th>
<td><?php echo $first_name; ?></td>
<td>
<div class="form-group <?php echo (!empty($user_firstName_err)) ? 'has-error' : ''; ?>">
<input type="text" name="user_firstName" class="form-control"
value="<?php echo $first_name; ?>">
<span class="help-block"><?php echo $user_firstName_err; ?></span>
</div>
</td>
</tr>
<tr>
<th>Last Name</th>
<td><?php echo $last_name; ?></td>
<td>
<div class="form-group <?php echo (!empty($user_lastName_err)) ? 'has-error' : ''; ?>">
<input type="text" name="lastName" class="form-control" value="<?php echo $first_name; ?>">
<span class="help-block"><?php echo $user_lastName_err; ?></span>
</div>
</td>
</tr>
<tr>
<th>Address</th>
<td><?php echo $address; ?></td>
<td>
<div class="form-group <?php echo (!empty($user_address_err)) ? 'has-error' : ''; ?>">
<input type="text" name="address" class="form-control" value="<?php echo $address; ?>">
<span class="help-block"><?php echo $user_address_err; ?></span>
</div>
</td>
</tr>
<tr>
<th>City</th>
<td><?php echo $city; ?></td>
<td>
<div class="form-group <?php echo (!empty($user_city_err)) ? 'has-error' : ''; ?>">
<input type="text" name="city" class="form-control" value="<?php echo $city; ?>">
<span class="help-block"><?php echo $user_city_err; ?></span>
</div>
</td>
</tr>
<tr>
<th>State</th>
<td><?php echo $state; ?></td>
<td>
<div class="form-group <?php echo (!empty($user_state_err)) ? 'has-error' : ''; ?>">
<input type="text" name="state" class="form-control" value="<?php echo $state; ?>">
<span class="help-block"><?php echo $user_state_err; ?></span>
</div>
</td>
</tr>
<tr>
<th>Zip</th>
<td><?php echo $zip; ?></td>
<td>
<div class="form-group <?php echo (!empty($user_zip_err)) ? 'has-error' : ''; ?>">
<input type="text" name="zip" class="form-control" value="<?php echo $zip; ?>">
<span class="help-block"><?php echo $user_zip_err; ?></span>
</div>
</td>
</tr>
<tr>
<th>Email</th>
<td><?php echo $email; ?></td>
<td>
<div class="form-group <?php echo (!empty($user_email_err)) ? 'has-error' : ''; ?>">
<input type="text" name="email" class="form-control" value="<?php echo $email; ?>">
<span class="help-block"><?php echo $user_email_err; ?></span>
</div>
</td>
</tr>
</table>
<div class="form-group">
<input type="submit" name="" class="btn btn-warning" value="Make Changes">
</div>
</form>
<p>
<a href="./showAllUsers.php" type="reset" class="btn btn-default" value="Back">Back</a>
<a href="./php_scripts/sign_out.php" class="btn btn-danger">Sign Out of Your Account</a>
</p>
</div>
</body>
</html>