-
Notifications
You must be signed in to change notification settings - Fork 0
/
setting.php
236 lines (189 loc) · 7.88 KB
/
setting.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
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
<!DOCTYPE html>
<html lang="en">
<?php
session_start();
$_SESSION['PrevPage'] ="setting.php";
?>
<head>
<title>STARTSAW</title>
<meta charset="utf-8">
<!-- icon webpage ----------------------------------------->
<link rel="icon" href="favicon.ico" type="image" sizes="16x16">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet" type="text/css">
<!-- <link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet" type="text/css"> -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<!-- <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css"> -->
<link rel="stylesheet" media="all" href="css/footer.css" />
<link rel="stylesheet" media="all" href="css/common.css" />
<link rel="stylesheet" media="all" href="css/login.css" />
<script src="js/common.js"></script>
<script src="js/changeSetting.js"></script>
<?php
if(isset($_SESSION['username'])) {
echo '<script src="js/message_updates.js"></script>';
}
?>
</head>
<body>
<?php
require "navbar.php";
?>
<?php
if(isset($_SESSION['username'])){
echo'
<div class="container">
<div class="body" id="settings">
<form action="script/changeSettings.php" method="POST" name="settingsForm" class="sky-form" enctype="multipart/form-data">
<header>Update Information</header>';
require "db/mysql_credentials.php";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
$user = $_SESSION['username'];
$sql = "SELECT user.*, city.Name as Cityname FROM user, city
WHERE Username='" . $user . "' AND user.City = city.ID ";
$result = mySQLi_query($conn, $sql) or die("Error query".$sql);
while ($row = mySQLi_fetch_array($result)) {
$cityName = $row['Cityname'];
echo '
<fieldset>
<section>
<label class="input" >
<a href="change_password.php"><button type="button" class="change-password-button" >
Change Password </button></a>
</label>
</section>
<section>
<label class="input" >
<p class="errorLogin" id="errorSettingsBox"><br></p>
</label>
</section>
<section>
<label class="input">
Username [uneditable]
</label>
<label class="input">
<input type="text" placeholder="Username" id="userChange" name="userChange" readonly
value="'.$row['Username'].'">
</label>
</section>
<section>
<label class="input">
Email
</label>
<label class="input">
<input type="text" placeholder="Email address" id="emailChange" name="emailChange" onclick="removeErrorChange()" onkeyup="removeErrorChange()" value="'.$row['Email'].'">
<b class="tooltip tooltip-bottom-right">Needed to verify your account</b>
</label>
</section>
</fieldset>
<fieldset>
<section>
<label class="input">
Date of Birth
</label>
<label class="input">
<input type="date" id="dateChange" name="dateChange" onclick="removeErrorChange()"
value="' . $row['Date_of_birth'] . '">
</label>
</section>
</fieldset>
<fieldset>
<div class="row">
<section class="col col-6">
<label class="input">
Name
</label>
<label class="input">
<input type="text" placeholder="First name" id="nameChange" name="nameChange" onclick="removeErrorChange()" onkeyup="removeErrorChange()" value="' . $row['Name'] . '">
</label>
</section>
<section class="col col-6">
<label class="input">
Surname
</label>
<label class="input">
<input type="text" placeholder="Last name" id="surnameChange" name="surnameChange" onclick="removeErrorChange()" onkeyup="removeErrorChange()" value="' . $row['Surname'] . '">
</label>
</section>
</div>
<section>
<label class="input">
Gender
</label>
<label class="select">';
if ($row['Gender'] == "male") {
echo "
<select onclick='removeErrorChange' name='gender' id='gender'>
<option value='male' selected>Male</option>
<option value='female'>Female</option>
</select>
";
} else {
echo "
<select onclick='removeErrorChange' name='gender' id='gender'>
<option value='male'>Male</option>
<option value='female' selected>Female</option>
</select>
";
}
echo '
<i></i>
</label>
</section>
</fieldset>
<fieldset>
<section>
<label class="input">
City of Birth
</label>
<label class="select">
<select onclick="removeErrorChange()" name="cityChange" id="cityChange">
<option value="not-selected" selected disabled>City</option>';
$sql = "SELECT ID, Name
FROM city";
$result = $conn->query($sql);
while($row = $result->fetch_assoc()) {
$id = $row['ID'];
$city = $row['Name'];
if (strlen($city) != 0) {
if(strcmp($cityName, $city) == 0)
echo "<option selected value='".$id."'>" . $city . "</option>";
else
echo "<option value='".$id."'>" . $city . "</option>";
}
}
$conn->close();
echo '
</select>
<i></i>
</label>
</section>
<section>
<label class="input">
Profile Picture
</label>
<label class="input">
<input type="file" accept="image/*" id="image" name="image" onclick="removeErrorChange()">
</label>
</section>
</fieldset>
<footer>
<button type="button" onclick="checkSettings()" class="button">UPDATE</button>
</footer>
</form>
<br><br>
</div>
</div>';
}
}
else
header("location: index.php");
?>
<?php
require "footer.php";
?>
</body>
</html>