-
Notifications
You must be signed in to change notification settings - Fork 3
/
profile.php
132 lines (103 loc) · 3.9 KB
/
profile.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
<?php
session_start();
include 'database.php';
$dbConn = getDatabaseConnection();
function getImages() {
global $dbConn;
$sql = "SELECT * FROM pictures WHERE userID = :userID";
$stmt = $dbConn->prepare($sql);
$stmt->execute(array(":userID"=> $_SESSION['user_id']));
$records = $stmt->fetchAll();
$j = 0;
echo "<div class='postedImages'>";
for($i=0; $i < count($records); $i++) {
echo "<img src='downloadFile.php?imageID=" . $records[$i]["imageID"] ."' width='300px'height='300px'". "' id='images'>";
$j++;
if($j % 3 == 0) {
echo "<br>";
}
}
echo "</div>";
}
function getProfilePicture() {
global $dbConn;
$sql = "SELECT * FROM profile_pictures WHERE userID = :userID";
$stmt = $dbConn->prepare($sql);
$stmt->execute(array(":userID"=> $_SESSION['user_id']));
$records = $stmt->fetchAll();
// echo "<br> records: <br>";
// print_r($records);
if(count($records) == 0) {
echo "<img src='images/avatar.png' class='profilePic' alt='Avatar' style='border-radius: 50%; width:10%'>";
} else {
echo "<img src='downloadProfilePicture.php?imageID=" . $records[0]["imageID"] . "' class='profilePic' style='border-radius: 50%; width:10%'>";
}
}
function getLimeData(){
global $dbConn;
$sql = "SELECT * FROM lime WHERE userID = :user_id";
$stmt = $dbConn->prepare($sql);
$stmt->execute(array(":user_id"=> $_SESSION['user_id']));
$records = $stmt->fetchAll();
if(count($records) == 1){
echo "<br><div id= 'bio'><h3>Referral Code:<br> <h3>" . $records[0]["referralCode"] . " <br>History:<br> I've been on " . $records[0]['rides'] . " rides</div>";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?php echo "@{$_SESSION['username']}" ?> | Scoot</title>
<link rel="stylesheet" type="text/css" href="styles/profilePageStyle.css">
<link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="icon" type="image/png" sizes="96x96" href="icon/favicon-96x96.png">
</head>
<body>
<h1><img src="images/scoot.png" id="logo" onclick="window.location.href='home.php'" style="cursor:pointer">
<div id="nav_div">
<nav>
<a style="margin-right:200px"href="home.php"> Home </a>
<a href="logout.php"> Logout </a>
</nav>
</div>
<select id = "settingsSelect">
<option value="0">Settings</option>
<option value="1">Change Username</option>
<option value="2">Change Password</option>
<option value="3">Delete Account</option>
</select>
<div id = "profileData">
<?php
getProfilePicture();
echo "<br>";
getLimeData();
?>
<h2><?php echo "@{$_SESSION['username']}" ?></h2>
<div align="center" class="postedImages">
<?php
getImages();
?>
</div>
</div>
</body>
</html>
<script>
$("#settingsSelect").change(onSettingsChange);
function onSettingsChange(){
if($("#settingsSelect").val() != "0"){
if($("#settingsSelect").val() == "1"){
var url = "usernameChange.php";
}
else if($("#settingsSelect").val() == "2"){
var url = "passwordChange.php";
}
else if($("#settingsSelect").val() == "3"){
var url = "deleteProfile.php";
}
window.location.replace(url);
}
}
</script>