-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathview_profile.php
More file actions
113 lines (100 loc) · 3.77 KB
/
Copy pathview_profile.php
File metadata and controls
113 lines (100 loc) · 3.77 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
<?php
session_set_cookie_params(30 * 60, "/; samesite=Strict", $_SERVER['HTTP_HOST'], 1, 0);
session_start();
if (!isset($_SESSION["user"])){
header("location:login.php");
exit();
}
?>
<!DOCTYPE html>
<!--
Project Name: Cougar Rescue Forum
Course: CIS444
Description: This file is the html for a student's profile page.
The file contains the profile layout and the corresponding
javascript dynamically fills the information from the database
which will be implemented later.
-->
<html lang="en">
<head>
<title>Cougar Rescue Forum</title>
<meta charset="utf-8"/>
<link rel="icon" href="images/cr_logo.png" type="image/x-icon" />
<script type="text/javascript" src="nav.js"></script>
<script type="text/javascript" src="view_profile.js"></script>
<link rel="stylesheet" href="cougar_rescue.css"/>
</head>
<body id="view_profile" class="pagestyle">
<div id="navlist" class="navlist">
<div>
<img class = "logo" src="images/cr_logo_plain.png" alt="Cougar Rescue Forum Logo"/>
</div>
<form id="logoutForm" method="post" action="logout.php">
<input name="logout" aria-label="logout" type="submit" class="logoutNav" value="Logout"/>
</form>
<a href="search.php">Search</a>
<a href="view_profile.php">Profile</a>
<a href="main.php">Home</a>
</div>
<div id="profile_info_div" class="forum-div profile-size">
<h1>My Profile</h1>
<div class="profile-picture">
<div id="profile-picture-div" >
</div>
</div>
<div class="profile-format">
<div class="sub-title floatright">
<div id="user-info">
<p class="profile-text border-bottom-div">Personal Information <a href="edit_profile.php" class="nolink small-font floatright" >
Edit Profile<!--<img src="images/edit.png" alt="Edit Profile" class="edit-icon ">--></a></p>
<!--JS-->
</div>
<div id="courses">
<p class="profile-text border-bottom-div">My Courses</p>
<!--JS-->
</div>
<div id="signature">
<p class="profile-text border-bottom-div">Signature</p>
</div>
</div>
</div>
</div>
<?php
$db = mysqli_connect("db", "root", "test", "myDb");
//$db = mysqli_connect("db", "group3", "g5tw9ShSexHH", "group3");
if (mysqli_connect_errno()) {
print "Connect failed: " . mysqli_connect_error();
exit();
}
$email = $_SESSION["user"];
//print $email;
$query = 'SELECT u.fname, u.lname, u.email, u.profilePicture, u.signature FROM Users u WHERE u.email ="' . $email . '";';
//print $query;
$result = mysqli_query($db, $query);
if (!$result) {
print '<script type="text/javascript"> alert("Error: the query could not be executed."' . mysqli_error() . ');</script>';
exit();
}
$rows = array();
while($r = mysqli_fetch_assoc($result)) {
$values = array_values($r);
$rows[] = $values;
}
//print json_encode($rows);
$crs = 'SELECT GROUP_CONCAT(uc.crsNumber SEPARATOR ", ") as "Courses" FROM Users u, User_Courses uc WHERE u.email = uc.email AND u.email ="'. $email . '";';
$result = mysqli_query($db, $crs);
if (!$result) {
print '<script type="text/javascript"> alert("Error: the query could not be executed."' . mysqli_error() . ');</script>';
exit();
}
$courses = array();
while($r = mysqli_fetch_assoc($result)) {
$values = array_values($r);
$courses[] = $values;
}
//print json_encode($courses);
print '<script type="text/javascript"> retrieveInformation(' . json_encode($rows) . ',' . json_encode($courses) . ');</script>';
mysqli_close($db);
?>
</body>
</html>