This repository was archived by the owner on Nov 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUpdateUser.php
More file actions
187 lines (185 loc) · 10.4 KB
/
UpdateUser.php
File metadata and controls
187 lines (185 loc) · 10.4 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
<?php
include('session.php');
include('SQLFunctions.php');
$table = 'users_enc';
$targetUserID = filter_input(INPUT_GET, "userID", FILTER_SANITIZE_NUMBER_INT);
$userRole = $_SESSION['role'];
$title = "SVBX - Update User";
$Loc = "SELECT Username, Role, firstname, lastname, Email, Company, inspector, bdPermit FROM $table WHERE UserID = $targetUserID";
include('filestart.php');
if($userRole < 30) {
header('location: unauthorised.php');
exit;
}
$link = f_sqlConnect();
?>
<header class="container page-header">
<h1 class="page-title">Update User Information</h1>
</header>
<?php if($stmt = $link->prepare($Loc)) {
$stmt->execute();
$stmt->bind_result($username, $targetRole, $firstname, $lastname, $email, $company, $inspector, $bdPermit);
while ($stmt->fetch()) {
echo "
<div class='container main-content'>";
if (!empty($_SESSION['errorMsg'])) {
echo "
<div class='thin-grey-border bg-yellow pad'>
<p class='mt-0 mb-0'>{$_SESSION['errorMsg']}</p>
</div>";
unset($_SESSION['errorMsg']);
}
if ($userRole >= 30) {
echo "
<form action='UpdateUserCommit.php' method='POST' onsubmit='' />
<input type='hidden' name='userID' value='$targetUserID'>
<table class='table'>
<tr class='usertr'>
<th class='userth'>First name:</td>
<td class='usertd'>
<input type='text' name='firstname' maxlength='25' required value='$firstname'/>
</td>
</tr>
<tr class='usertr'>
<th class='userth'>Last name:</td>
<td class='usertd'>
<input type='text' name='lastname' maxlength='25' required value='$lastname'/>
</td>
</tr>
<tr class='usertr'>
<th class='userth'>Email Address:</td>
<td class='usertd'>
<input type='text' name='email' maxlength='55' required value='$email'/>
</td>
</tr>
<tr class='usertr'>
<th class='userth'>Username:</td>
<td class='usertd'>
<input type='text' name='username' maxlength='25' required value='$username'/>
</td>
</tr>
<tr class='usertr'>
<th class='userth'>Company:</td>
<td class='usertd'>
<input type='text' name='company' maxlength='25' required value='$company'/>
</td>
</tr>
<tr class='usertr'>
<th class='userth'>Password:</td>
<td class='usertd'>
<input type='password' name='password' maxlength='25' value=''/><br />
<i>only complete if you want to change a users password</i>
</td>
</tr>
<tr class='usertr'>
<th class='userth'>Confirm Password:</td>
<td class='usertd'>
<input type='password' name='conPwd' maxlength='25' value=''/><br />
<i>confirm new password</i>
</td>
</tr>";
if ($userRole >= 40) {
echo "
<tr class='usertr'>
<th class='userth' rowspan='4'>Role:</td>
<td class='usertd'>
<input type='radio' name='role' value='40'";
echo ( $targetRole === 40 ? ' checked' : '' );
echo "/>Super Admin
</td>
</tr>
<tr class='usertr'>
<td class='usertd'>
<input type='radio' name='role' value='30'";
echo ( $targetRole === 30 ? ' checked' : '' );
echo "/>Administrator
</td>
</tr>
<tr class='usertr'>
<td class='usertd'>
<input type='radio' name='role' value='20'";
echo ( $targetRole === 20 ? ' checked' : '' );
echo "/>User
</td>
</tr>
<tr class='usertr'>
<td class='usertd'>
<input type='radio' name='role' value='10'";
echo ( $targetRole === 10 ? ' checked' : '' );
echo "/>Read Only
</td>
</tr>";
} elseif ($userRole >= 30) {
echo "
<tr class='usertr'>
<th class='userth' rowspan='3'>Role:</td>
<td class='usertd'>
<input type='radio' name='role' value='30'";
echo ( $targetRole === 30 ? ' checked' : '' );
echo "/>Administrator
</td>
</tr>
<tr class='usertr'>
<td class='usertd'>
<input type='radio' name='role' value='20'";
echo ( $targetRole === 20 ? ' checked' : '' );
echo "/>User
</td>
</tr>
<tr class='usertr'>
<td class='usertd'>
<input type='radio' name='role' value='10'";
echo ( $targetRole === 10 ? ' checked' : '' );
echo "/>Read Only
</td>
</tr>";
} else {
}
echo "
</table>
<div id='inspector-fieldset' class='row item-margin-bottom'>
<h6 class='col-md-4'>Can create Inspector Daily Reports?</h6>
<div id='inspector-options' class='col-md-8'>
<input type='radio' id='inspector-yes' name='inspector' value='1' required ";
echo ($inspector === 1 ? 'checked' : '');
echo "
/>
<label for='inspector-yes'>Yes</label>
<input type='radio' id='inspector-no' name='inspector' value='0' required ";
echo ($inspector === 0 ? 'checked' : '');
echo "
/>
<label for='inspector-no'>No</label>
</div>
</div>
<div class='row item-margin-bottom'>
<h6 class='col-md-4'>Can see BART deficiencies?</h6>
<div class='col-md-8'>
<input type='radio' id='bdPermit_yes' name='bdPermit' value='1' ";
echo ($bdPermit ? 'checked' : '');
echo "
/>
<label for='bdPermit_yes'>Yes</label>
<input type='radio' id='bdPermit_no' name='bdPermit' value='0' ";
echo ($bdPermit ? '' : 'checked');
echo "
/>
<label for='bdPermit_no'>No</label>
</div>
</div>
<div class='row item-margin-bottom'></div>
<input type='submit' value='submit' class='btn btn-primary btn-lg'/>
<input type='reset' value='reset' class='btn btn-primary btn-lg' />
</form>";
} else {
echo "<p style='text-align:center'>You do not have the authority to amend this user";
}
echo "</div>";
}
} else {
echo '<br>Unable to connect';
echo '<br />SQL: '.$Loc;
echo '<br />UserID: '.$targetUserID;
exit();
}
include('fileend.php') ?>