-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheditstudent.php
325 lines (251 loc) · 11.3 KB
/
editstudent.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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
<?php
session_start();
?>
<?php
if(!isset($_SESSION['id'])){
die(header("Location: error.php"));
}
?>
<?php
$id = $fname = $lname= $ename = $phone =$major = $wechat ="";
$id = $_GET['id'];
// echo $id;
include("project3connection.php");
// query base on id
$qs = "SELECT student.*, users.email as email, users.pw as pw FROM student JOIN users ON student.s_id = users.id WHERE s_id = '$id'";
$query = mysqli_query($dbc,$qs);
$num = mysqli_num_rows($query);
if($num!=0){
while($row = mysqli_fetch_array($query)){
// $id = $row['id'];
$fname = $row['firstName'];
$lname = $row['lastName'];
$ename = $row['englishName'];
$gender = $row['gender'];
$email = $row['email'];
$password = $row['pw'];
$phone = $row['phone'];
$wechat = $row['wechat'];
$bringfamily = $row['bringFamily'];
$firtTime = $row['retu'];
$level = $row['purpose'];
$faset = $row['faset6'];
$school = $row['school'];
$major = $row['major'];
$vacine = $row['vaccine'];
$attention = $row['attention'];
$anycomment = $row['scomment'];
$admincomment =$row['acomment'];
$pickup = $row['pickup'];
$info = $row['flightInfo'];
$afnum = $row['aflightnum'];
$name = $row['aairline'];
$date = $row['aDate'];
$time = $row['aTime'];
$fnum = $row['lflightnum'];
$laname = $row['lairline'];
$ldate = $row['lDate'];
$ltime = $row['lTime'];
$sluggage = $row['smalllug'];
$bluggage = $row['biglug'];
$flightcomment = $row['flightComment'];
}
}
if($_SERVER["REQUEST_METHOD"]== "POST"){
$id = $_POST['id'];
$fname = mysqli_real_escape_string($dbc, $_POST['firstName']);
$lname = mysqli_real_escape_string($dbc, $_POST['lastName']);
$ename = mysqli_real_escape_string($dbc, $_POST['englishname']);
$gender = mysqli_real_escape_string($dbc, $_POST['gender']);
$email = mysqli_real_escape_string($dbc, $_POST['email']);
$password = mysqli_real_escape_string($dbc, $_POST['pw']);
$phone = mysqli_real_escape_string($dbc, $_POST['phone']);
$wechat = mysqli_real_escape_string($dbc, $_POST['wechat']);
$bringfamily = mysqli_real_escape_string($dbc, $_POST['bringfamily']);
$firtTime = mysqli_real_escape_string($dbc, $_POST['firtTime']);
$level = mysqli_real_escape_string($dbc, $_POST['level']);
$faset = mysqli_real_escape_string($dbc, $_POST['faset']);
$school = mysqli_real_escape_string($dbc, $_POST['school']);
$major = mysqli_real_escape_string($dbc, $_POST['major']);
$vacine = mysqli_real_escape_string($dbc, $_POST['vacine']);
$attention = mysqli_real_escape_string($dbc, $_POST['attention']);
$anycomment = mysqli_real_escape_string($dbc, $_POST['anycomment']);
$admincomment = mysqli_real_escape_string($dbc, $_POST['admincomment']);
$pickup = mysqli_real_escape_string($dbc, $_POST['pickup']);
$info = mysqli_real_escape_string($dbc, $_POST['info']);
$afnum = mysqli_real_escape_string($dbc, $_POST['afnum']);
$name = mysqli_real_escape_string($dbc, $_POST['name']);
$date = mysqli_real_escape_string($dbc, $_POST['date']);
$time = mysqli_real_escape_string($dbc, $_POST['time']);
$fnum = mysqli_real_escape_string($dbc, $_POST['fnum']);
$laname = mysqli_real_escape_string($dbc, $_POST['laname']);
$ldate = mysqli_real_escape_string($dbc, $_POST['ldate']);
$ltime = mysqli_real_escape_string($dbc, $_POST['ltime']);
$sluggage = mysqli_real_escape_string($dbc, $_POST['sluggage']);
$bluggage = mysqli_real_escape_string($dbc, $_POST['bluggage']);
$flightcomment = mysqli_real_escape_string($dbc, $_POST['flightcomment']);
echo "This is user id ".$id;
$qs = "UPDATE student SET
firstName='$fname',
lastName='$lname',
englishName='$ename',
gender='$gender',
phone='$phone',
wechat='$wechat',
bringFamily='$bringfamily',
retu='$firtTime',
purpose='$level',
faset6='$faset',
school='$school',
major='$major',
vaccine='$vacine',
attention='$attention',
scomment='$anycomment',
acomment='$admincomment',
pickup='$pickup',
flightInfo='$info',
aflightnum='$afnum',
aairline='$name',
aDate='$date',
aTime='$time',
lflightnum='$fnum',
lairline='$laname',
lDate='$ldate',
lTime='$ltime',
smalllug='$sluggage',
biglug='$bluggage',
flightComment='$flightcomment'
WHERE s_id='$id'";
//$qs = "UPDATE student SET firstname = '$fname', lastName = '$lname', englishname = '$ename', phone = '$phone', wechat = '$wechat' WHERE s_id = '$id'";
mysqli_query($dbc,$qs);
$num = mysqli_affected_rows($dbc); // should be 1
$qs2 = "UPDATE users
SET email = '$email',
pw ='$password'
WHERE id = '$id'";
mysqli_query($dbc,$qs2);
$num2= mysqli_affected_rows($dbc); // should be 1
if($num ==1|| $num2 ==1){
echo"Update successful!";
}
else{
echo "Something went wrong";
}
}
?>
<html>
<head>
<title>Update Student Profile</title>
<style>
.error{color: #FF0000;}
</style>
</head>
<body>
<?php
include "adminnav.php";
?>
<h3 style = "text-align: center"> Update Student Profile </h3>
<form action ="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"method ="post">
<input type = "hidden" name = "id" size="20" maxlength="50" value ="<?php echo$id; ?>">
First Name <input type = "text" name = "firstName" size="20" maxlength="50" value ="<?php echo$fname; ?>">
<br>
Last Name <input type = "text" name = "lastName" size="20" maxlength="50" value ="<?php echo$lname; ?>">
<br>
English name <input type = "text" name = "englishname" size="20" maxlength="50" value ="<?php echo$ename; ?>">
<br>
Email <input type = "text" name = "email" size="20" maxlength="50" value ="<?php echo$email; ?>">
<br>
pw <input type = "text" name = "pw" size="20" maxlength="50" value ="<?php echo$password; ?>">
<br>
phone <input type = "text" name = "phone" size="20" maxlength="50" value ="<?php echo$phone; ?>">
<br>
wechat <input type = "text" name = "wechat" size="20" maxlength="50" value ="<?php echo$wechat; ?>">
<br>
Gender:
<input type="radio" name="gender" <?php if (isset($gender)&& $gender =="female") echo"checked";?> value="female" > Female
<input type="radio" name="gender" <?php if (isset($gender)&& $gender =="male") echo"checked";?> value="male" > Male
<input type="radio" name="gender" <?php if (isset($gender)&& $gender =="other") echo"checked";?> value="other" > Other
<br>
Brining family/relatives or not:
<input type="radio" name="bringfamily" <?php if (isset($bringfamily)&& $bringfamily =="yes") echo"checked";?> value="yes" > Yes
<input type="radio" name="bringfamily" <?php if (isset($bringfamily)&& $bringfamily =="no") echo"checked";?> value="no" > No
<br>
Are you a returnings student or first-time student?
<input type="radio" name="firtTime" <?php if (isset($firtTime)&& $firtTime =="Returning") echo"checked";?> value="Returning" > Returning
<input type="radio" name="firtTime" <?php if (isset($firtTime)&& $firtTime =="FirstTime") echo"checked";?> value="FirstTime" > FirstTime
<br>
I am comming to the US to be a
<select name = "level">
<option <?php if(isset($level)&&$level =="blank") echo "selected = 'selected'";?> value = "blank"> -- Select --</option>
<option <?php if(isset($level)&&$level =="ud") echo "selected = 'selected'";?> value = "ud"> undergraduate student</option>
<option <?php if(isset($level)&&$level =="gd") echo "selected = 'selected'";?> value = "gd"> graduate student</option>
<option <?php if(isset($level)&&$level =="vs") echo "selected = 'selected'";?> value = "vs"> visiting scholar</option>
<option <?php if(isset($level)&&$level =="ot") echo "selected = 'selected'";?> value = "ot"> other</option>
</select>
Are you attending FASET? If you will attend on 08/16, please choose FASET6
<select name = "faset">
<option <?php if(isset($faset)&&$faset =="na") echo "selected = 'selected'";?> value = "na">Not attending </option>
<option <?php if(isset($faset)&&$faset =="f6") echo "selected = 'selected'";?> value = "f6">FASET 6</option>
</select>
<br>
School you are graduated from: <input type ="text" name= "school" value = "<?php echo$school;?>"><br><br>
Major:<input type ="text" name= "major" value = "<?php echo$major;?>">
<br>
Did you already get COVID Vaccination: <input type ="text" name= "vacine" value = "<?php echo$vacine;?>"><br><br>
Special Attention:
<input type="radio" name="attention" <?php if (isset($attention)&& $attention =="Yes") echo"checked";?> value="Yes" > Yes
<input type="radio" name="attention" <?php if (isset($attention)&& $attention =="No") echo"checked";?> value="No" > No
<br>
Any Comment:<br> <textarea name ="anycomment" rows ="5" cols="40"> <?php echo $anycomment;?></textarea> <br><br>
Admin Comment: <br><textarea name ="admincomment" rows ="5" cols="40"> <?php echo $admincomment;?></textarea> <br><br>
Do you need airport pickup?
<input type="radio" name="pickup" <?php if (isset($pickup)&& $pickup =="yes") echo"checked";?> value="yes" > Yes
<input type="radio" name="pickup" <?php if (isset($pickup)&& $pickup =="no") echo"checked";?> value="no" > No
<br>
Do you have the flight information?
<input type="radio" name="info" <?php if (isset($info)&& $info =="yes") echo"checked";?> value="yes" > Yes
<input type="radio" name="info" <?php if (isset($info)&& $info =="no") echo"checked";?> value="no" > No
<br>
if yes, arriving Atlanta - Flight Number
<input type ="text" name= "afnum" value = "<?php echo$afnum;?>">
<br>
Arriving Atlanta - Airline Name
<input type ="text" name= "name" value = "<?php echo$name;?>">
<br>
Arriving Atlanta - Date
<input type ="text" name= "date" value = "<?php echo$date;?>">
(Use mm/dd/yyyy formate)
<br>
Arriving Atlanta - Time
<span class = "error">*</span><input type ="text" name= "time" value = "<?php echo$time;?>">
(Please use format hh:mm such as 17:20 or 08:15)
<br>
Leaving - Flight Number:
<input type ="text" name= "fnum" value = "<?php echo$fnum;?>">
<br>
Leaving - Airline Name:
<input type ="text" name= "laname" value = "<?php echo$laname;?>">
<br>
Leaving - Date
<input type ="text" name= "ldate" value = "<?php echo$ldate;?>">
(Use mm/dd/yyy formate)
<br>
Leaving - Time
<input type ="text" name= "ltime" value = "<?php echo$ltime;?>">
(Please use format hh:mm such as 17:20 or 08:15)
<br>
How many piece of big luggage
<input type ="text" name= "bluggage" value = "<?php echo$bluggage;?>">
<br>
How many piece of small luggage
<input type ="text" name= "sluggage" value = "<?php echo$sluggage;?>">
<br>
</div>
<br>
Flight Comment:<br>
<textarea name ="flightcomment" rows ="5" cols="40"> <?php echo $flightcomment;?></textarea> <br><br>
<br><br>
<input type="submit" value ="Update User">
</form>
</body>
</html>