-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser_profile.php
155 lines (151 loc) · 7.22 KB
/
user_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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<?php
include_once "includes/sessioncheck.php";
include_once "includes/database.php";
?>
<!DOCTYPE html>
<html lang="en">
<head>
<script src="scripts/jquery-3.5.1.min.js"></script>
<meta charset="UTF-8" />
<link rel="shortcut icon" href="images/shirtlogo.png" type="image/x-icon">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="styles/style.css" />
<link rel="stylesheet" href="styles/user_profile.css" />
<title>User Profile</title>
</head>
<body>
<!-- ----------------------------------- TOP-BAR ----------------------------------- -->
<?php include "includes/storetopbar.php"; ?>
<!-- ----------------------------------- TOP-BAR ----------------------------------- -->
<div class="body-wrapper">
<div></div>
<!-- ----------------------------------- BODY ----------------------------------- -->
<div class="content-wrapper container">
<?php
$userId = $_SESSION["userid"];
$user = mysqlidb::fetchRow("SELECT * FROM user WHERE UserId=$userId");
$purchases = mysqlidb::fetchAllRows("SELECT * FROM productorder WHERE UserId=$userId ORDER BY PurchaseDate DESC");
?>
<div class="profile-wrapper h-4">
<div class="profile-navbar">
<a href="user_profile.php">
<div class="profile-owner flex w-4">
<img class="profile-pic" src="<?php echo $user["UserImage"] ?>" alt="" />
<div class="profile-name"><?php echo $user["Username"] ?></div>
</div>
</a>
<a href="#my-profile" class="profile-menu-item flex active">
<div class="profile-menu-item-icon material-icons unselectable ruby">person</div>
<div class="profile-menu-item-name">My Profile</div>
</a>
<a href="#change-password" class="profile-menu-item flex">
<div class="profile-menu-item-icon material-icons unselectable ruby">lock</div>
<div class="profile-menu-item-name">Change Password</div>
</a>
<a href="inbox.php" class="profile-menu-item flex">
<div class="profile-menu-item-icon material-icons unselectable ruby">mail</div>
<div class="profile-menu-item-name">Inbox</div>
</a>
<a href="purchase_history.php#my-purchases" class="profile-menu-item flex">
<div class="profile-menu-item-icon material-icons unselectable ruby">shopping_basket</div>
<div class="profile-menu-item-name">My Purchases</div>
</a>
</div>
<div>
<?php
if (isset($_GET['message'])) {
if ($_GET['message'] == "error") {
echo '<div class="card-error">Error Occured</div>';
}
if ($_GET['message'] == "edited") {
echo '<div class="card-success">Successfully Edited</div>';
}
}
?>
<div id="my-profile"></div>
<div class="profile-body">
<div class="profile-body-header">My Profile</div>
<form action="update_user.php" method="POST" enctype="multipart/form-data">
<div class="form-input-group flex flex-column">
<label class="block">Profile Picture</label>
<div class="flex-wrapper flex-column flex-align-center flex-justify-center">
<img src="<?php echo $user["UserImage"] ?>" id="userImage" alt="">
<input accept="image/jpeg, image/png" type="file" name="picture" id="picture" />
<label class="w-2" for="picture">Choose an Image</label>
</div>
</div>
<div class="form-input-group">
<label class="block" for="username">Username</label>
<input type="text" id="username" name="username" value="<?php echo $user["Username"] ?>" disabled />
</div>
<div class="form-input-group">
<label class="block" for="email">Email</label>
<input type="text" id="email" name="email" value="<?php echo $user["Email"] ?>" />
</div>
<div class="form-input-group">
<label class="block" for="gender">Gender</label>
<select name="gender" id="gender">
<option value="Male" <?php echo $user["Gender"] == "Male" ? "selected" : ""; ?>>Male</option>
<option value="Female" <?php echo $user["Gender"] == "Female" ? "selected" : ""; ?>>Female</option>
<option value="None" <?php echo $user["Gender"] == "None" ? "selected" : ""; ?>>Prefer not to say</option>
</select>
</div>
<div class="form-input-group">
<label class="block" for="dob">Date of Birth</label>
<input type="date" id="dob" name="dob" value="<?php echo $user["DOB"] ?>" />
</div>
<div class="form-input-group">
<label class="block" for="address">Address</label>
<textarea id="address" name="address" rows="4" maxlength="240"><?php echo $user["Address"] ?></textarea>
</div>
<div class="form-input-group text-center">
<input class="w-2" type="submit" id="profile-submit" value="Save" disabled />
</div>
</form>
</div>
<div id="change-password"></div>
<div class="profile-body">
<div class="profile-body-header">Change Password</div>
<?php
if (isset($_GET["message"])) {
switch ($_GET["message"]) {
case 'same_password':
echo '<div class="card-error">Your new password cannot be the same as your old password!</div>';
break;
case 'wrong_password':
echo '<div class="card-error">Your old password provided is wrong!</div>';
break;
case 'ok_password':
echo '<div class="card-success">Successfully changed password!</div>';
break;
}
}
?>
<form action="change_password.php" method="POST">
<div class="form-input-group">
<label class="block" for="password">Change Password</label>
<input type="password" id="password" placeholder="Old Password" name="password" />
<input type="password" id="newpassword" placeholder="New Password" name="newpassword" />
</div>
<div class="form-input-group text-center">
<input class="w-2" type="submit" id="password-submit" value="Save" disabled />
</div>
</form>
</div>
</div>
</div>
</div>
<!-- ----------------------------------- BODY ----------------------------------- -->
<!-- ----------------------------------- FOOTER ----------------------------------- -->
<?php include "includes/footer.php" ?>
<!-- -----------------------------------FOOTER----------------------------------- -->
</div>
</body>
<script src="scripts/main.js"></script>
<?php include "includes/store_scripts.php"; ?>
<script src="scripts/user_profile_page.js"></script>
<script>
HandleHash();
window.addEventListener("hashchange", HandleHash);
</script>
</html>