forked from emilysim00/StudyLah
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofile.php
More file actions
173 lines (158 loc) · 7.7 KB
/
Copy pathprofile.php
File metadata and controls
173 lines (158 loc) · 7.7 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
<?php
@ob_start();
session_start();
date_default_timezone_set('Asia/Singapore');
if (!isset( $_SESSION['NUSEmail'] ) ) {
// Redirect them to the login page
if ($_SERVER['SERVER_PORT'] == '80' || $_SERVER['SERVER_PORT'] =='443'){
header("Location: http://localhost/orbital/signup.php");
}
else{
header("Location: http://localhost:8080/orbital/signup.php");
}
}
?>
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<link rel="icon" href="img\studylah_logo.jpg" type="image/jpg">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300&display=swap" rel="stylesheet">
<link rel="stylesheet" href="css\navbar.css">
<link rel="stylesheet" href="css\profile.css">
<title>StudyLah</title>
</head>
<body style="font-family: 'Inter', sans-serif;">
<!--navbar-->
<?php include('header.php');?>
<!--profile section-->
<section style="background-color:#424240;">
<section id="profilesection">
<div>
<div class="bigtext">My Profile <span id="editprofile">
<?php
//edit profile button
if ($_SERVER['SERVER_PORT'] == '80' || $_SERVER['SERVER_PORT'] =='443'){
echo "<button onclick=\"location.href='http://localhost/orbital/editprofile.php'\">Edit profile</button>";
}
else{
echo "<button onclick=\"location.href='http://localhost:8080/orbital/editprofile.php'\">Edit profile</button>";
}
?>
</span>
</div>
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname= "orbital";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$useremail=$_SESSION['NUSEmail'];
$sqlgetuser="SELECT * FROM users WHERE NUSEmail='$useremail'";
$resultgetuser=mysqli_query($conn,$sqlgetuser);
if(mysqli_num_rows($resultgetuser) > 0){//valid
while($rowgetuser=mysqli_fetch_array($resultgetuser)){
//display profile picture
$profilepic=$rowgetuser['ProfilePic'];
if($profilepic=="" || $profilepic==NULL){
echo "<div><img src=\"img/user.png\" id=\"profilepic\" alt=\"profilepic\" width=\"250px\" height=\"250px\"></div>";
}
else{
echo "<div><img src=\"userprofilepic/$profilepic\" id=\"profilepic\" alt=\"profilepic\" width=\"250px\" height=\"250px\"></div>";
}
//display name
$fullname= $rowgetuser['FullName'];
echo "<div style=\"font-size:25px;\">$fullname</div>";
//display course and year
$course= $rowgetuser['Course'];
$yearofstudy = $rowgetuser['YearOfStudy'];
echo "<div style=\"color:gray;\">$course Year $yearofstudy</div>";
//display bio
$bio = $rowgetuser['Bio'];
if($bio != "" || $bio!=NULL){
echo "<div id=\"profilebio\"> \" $bio \"</div>";
}
echo "<hr class=\"hrstyle\">";
//Other details -- table
$residencystat= $rowgetuser['ResidencyStatus'];
$currentmod= $rowgetuser['CurrentMod'];
$pastmod= $rowgetuser['PastMod'];
$cca= $rowgetuser['CCA'];
echo "<div style=\"font-size:20px;text-decoration:underline;\">Other Details</div>";
//residency
echo "<table class=\"centertable\">
<tr><td>Residency:</td>";
if($residencystat=="Yes"){
echo "<td class=\"tdsecond\">Stays in campus</td>";
}
else{
echo "<td class=\"tdsecond\">Does not stay in campus</td>";
}
echo "</tr>";
//curent mods
echo "<tr>
<td>Current Mods:</td><td class=\"tdsecond\">";
if ($currentmod == "" || $currentmod == NULL){
echo "None";
}
else{
$currentmodexplode=preg_split('/[\ \n\,]+/', $currentmod);//split string by regular expressions comma, space e.g and put into array
for($eachmod = 0;$eachmod < count($currentmodexplode); $eachmod++){
$getmods=$currentmodexplode[$eachmod];
echo "$getmods<br>";
}
}
echo "</td></tr>";
//past mods
echo "<tr>
<td>Past Mods:</td><td class=\"tdsecond\">";
if ($pastmod == "" || $pastmod == NULL){
echo "None";
}
else{
$pastmodexplode=preg_split('/[\ \n\,]+/', $pastmod);//split string by regular expressions comma, space e.g and put into array
for($eachpastmod = 0;$eachpastmod < count($pastmodexplode); $eachpastmod++){
$getpastmods=$pastmodexplode[$eachpastmod];
echo "$getpastmods<br>";
}
}
echo "</td></tr>";
//CCA or Clubs
echo "<tr>
<td>CCAs/Clubs</td><td class=\"tdsecond\">";
if ($cca == "" || $cca == NULL){
echo "None";
}
else{
$ccaexplode=explode(",", $cca);//split by comma
for($eachcca = 0;$eachcca < count($ccaexplode); $eachcca++){
$getcca=$ccaexplode[$eachcca];
echo "$getcca<br>";
}
}
echo "</td></tr>";
echo "</table>";
}
}
else{
if ($_SERVER['SERVER_PORT'] == '80' || $_SERVER['SERVER_PORT'] =='443'){
$url="http://localhost/orbital/signup.php";
header('Location:' . $url);
}
else{
$url="http://localhost:8080/orbital/signup.php";
header('Location:' . $url);
}
}
?>
</div>
</section>
</section>
</body>
</html>