-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstudent_profile.php
More file actions
180 lines (147 loc) · 8.29 KB
/
student_profile.php
File metadata and controls
180 lines (147 loc) · 8.29 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
<?php
session_start();
if (!isset($_SESSION['user_id']) || $_SESSION['user_type'] != 2) {
header("Location: login.php");
exit();
}
include "connection.php";
function test_input($data) {
if (is_null($data)) {
return '';
}
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
$user_id = $_SESSION['user_id'];
$result = mysqli_query($dbc, "SELECT first_name, last_name FROM apath_users WHERE id='$user_id'");
$user = mysqli_fetch_assoc($result);
$firstname = $user['first_name'];
$lastname = $user['last_name'];
$gender = $family = $type = $future = $faset = $school = $major = $email = $phone = $wechat = $covid = $password = $confirmpassword = $special = $comment = $admin = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$gender = isset($_POST["gender"]) ? test_input($_POST["gender"]) : '';
$family = isset($_POST["family"]) ? test_input($_POST["family"]) : '';
$type = isset($_POST["type"]) ? test_input($_POST["type"]) : '';
$future = test_input($_POST["future"]);
$faset = test_input($_POST["faset"]);
$school = test_input($_POST["school"]);
$major = test_input($_POST["major"]);
$email = test_input($_POST["email"]);
$phone = test_input($_POST["phone"]);
$wechat = test_input($_POST["wechat"]);
$covid = isset($_POST["covid"]) ? test_input($_POST["covid"]) : '';
$password = test_input($_POST["password"]); // Plain text password
$confirmpassword = test_input($_POST["confirmpassword"]);
$special = isset($_POST["special"]) ? test_input($_POST["special"]) : '';
$comment = test_input($_POST["comment"]);
$admin = test_input($_POST["admin"]);
$sql = "INSERT INTO apath_student (s_id, gender, family, student_type, future, faset, school, major, email, phone, wechat, covid, password, special, comment, admin_comments)
VALUES ('$user_id', '$gender', '$family', '$type', '$future', '$faset', '$school', '$major', '$email', '$phone', '$wechat', '$covid', '$password', '$special', '$comment', '$admin')
ON DUPLICATE KEY UPDATE gender='$gender', family='$family', student_type='$type', future='$future', faset='$faset', school='$school', major='$major', email='$email', phone='$phone', wechat='$wechat', covid='$covid', password='$password', special='$special', comment='$comment', admin_comments='$admin'";
if (mysqli_query($dbc, $sql)) {
echo "Record updated successfully";
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($dbc);
}
}
mysqli_close($dbc);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>APATH Personal Profile - STUDENT</title>
<link rel="stylesheet" href="apath.css">
</head>
<body>
<div class="container">
<h1>APATH</h1>
<?php
$current_page = basename($_SERVER['PHP_SELF']);
include "apath_nav.php";
?>
<br>
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post">
<h2>Personal Profile</h2>
<div class="form-group">
Last Name<span class="required">*</span>:
<input type="text" name="lastname" value="<?php echo $lastname; ?>" readonly><br><br>
First Name<span class="required">*</span>:
<input type="text" name="firstname" value="<?php echo $firstname; ?>" readonly><br><br>
Gender<span class="required">*</span>: <br>
<input type="radio" name="gender" value="Male" <?php if(isset($gender)&&$gender=="Male") echo "checked"; ?>> Male
<input type="radio" name="gender" value="Female" <?php if(isset($gender)&&$gender=="Female") echo "checked"; ?>> Female
<input type="radio" name="gender" value="Other" <?php if(isset($gender)&&$gender=="Other") echo "checked"; ?>> Other
<br><br>
Bringing family/relatives or not?<span class="required">*</span>: <br>
<input type="radio" name="family" value="Yes" <?php if(isset($family)&&$family=="Yes") echo "checked"; ?>> Yes
<input type="radio" name="family" value="No" <?php if(isset($family)&&$family=="No") echo "checked"; ?>> No
<br><br>
<br>
Are you a returning student or first-time student?<span class="required">*</span>: <br>
<input type="radio" name="type" value="Returning" <?php if(isset($type)&&$type=="Returning") echo "checked"; ?>> Returning
<input type="radio" name="type" value="First Time" <?php if(isset($type)&&$type=="First Time") echo "checked"; ?>> First Time
<br><br>
<br>
I'm coming to the U.S. to be a<span class="required">*</span>: <br>
<select name="future">
<option>-- Select --</option>
<option value="under" <?php if($future=="under") echo "selected";?>>Undergraduate Student</option>
<option value="grad" <?php if($future=="grad") echo "selected";?>>Graduate Student</option>
<option value="visit" <?php if($future=="visit") echo "selected";?>>Visiting Scholar</option>
<option value="other" <?php if($future=="other") echo "selected";?>>Other</option>
</select>
</span>
<br><br>
<br>
Are you attending FASET? If you will attend FASET on 08/16,
please choose FASET 6<span class="required">*</span>: <br>
<select name="faset">
<option>-- Select --</option>
<option value="not" <?php if($faset=="not") echo "selected";?>>NOT</option>
<option value="faset_6" <?php if($faset=="faset_6") echo "selected";?>>6</option>
<option value="faset_7" <?php if($faset=="faset_7") echo "selected";?>>7</option>
</select>
</span>
<br><br>
School you graduated from<span class="required">*</span>:
<input type="text" name="school" value="<?php echo $school; ?>"><br><br>
Major<span class="required">*</span>:
<input type="text" name="major" value="<?php echo $major; ?>"><br><br>
Email<span class="required">*</span>:
<input type="email" name="email" value="<?php echo $email; ?>"><br><br>
Phone (in case of emergency)<span class="required">*</span>:
<input type="phone" name="phone" value="<?php echo $phone; ?>"><br><br>
WeChat ID:
<input type="text" name="wechat" value="<?php echo $wechat; ?>"><br><br>
Did you already get COVID Vaccine?<span class="required">*</span>: <br>
<input type="radio" name="covid" value="Yes" <?php if(isset($covid)&&$covid=="Yes") echo "checked"; ?>> Yes
<input type="radio" name="covid" value="No" <?php if(isset($covid)&&$covid=="No") echo "checked"; ?>> No
<br><br>
Password<span class="required">*</span>:
<input type="password" name="password"><br><br>
Confirm Password<span class="required">*</span>:
<input type="password" name="confirmpassword"><br><br>
<br>
<br>
Special Attention?<span class="required">*</span>: <br>
<input type="radio" name="special" value="Yes" <?php if(isset($special)&&$special=="Yes") echo "checked"; ?>> Yes
<input type="radio" name="special" value="No" <?php if(isset($special)&&$special=="No") echo "checked"; ?>> No
<br><br>
<br>
Any Comments:
<textarea name="comment" rows="10" columns="50"><?php echo $comment; ?></textarea> <br><br>
Admin Comments:
<textarea name="admin" rows="10" columns="50"><?php echo $admin; ?></textarea>
<br><br>
<br><br>
<button type="submit">Submit</button>
</div>
</form>
<p class="footer"><a href="#">Covid Information and Guidelines</a></p>
</div>
</body>
</html>