-
Notifications
You must be signed in to change notification settings - Fork 3
/
user-settings.php
219 lines (181 loc) · 9.97 KB
/
user-settings.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
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
<?php
namespace classes;
require_once "classes/db-connector.php";
use classes\DBConnector;
use PDO;
session_start();
if(!isset($_SESSION["listener_id"])){
header("Location: user-login.php");
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Settings</title>
<link rel="icon" type="image/png" href="assets/logos/favicon.png">
<!-- Bootstrap 5.0.2 -->
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.8/dist/umd/popper.min.js" integrity="sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r" crossorigin="anonymous"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-9ndCyUaIbzAi2FUVXJi0CjmCapSmO7SnpJef0486qhLnuZ2cdeRhO02iuK6FUUVM" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.min.js" integrity="sha384-fbbOQedDUMZZ5KreZpsbe1LCZPVmfTnH7ois6mU1QK+m14rQ1l2bGBq41eYeM/fS" crossorigin="anonymous"></script>
<link rel="stylesheet" href="css/styles.css">
</head>
<body>
<!-- Topbar -->
<div>
<div class="topbar">
<div class="modal-layer" id="layer" onclick="toogleSidebar()"></div>
<nav class="navbar navbar-expand-lg nav-dashboard shadow">
<button onclick="myFunction()" class="navbar-toggler p-2 rounded w-auto" style="transform: rotate(180deg)">
<img src="./assets/slider-icon.svg" alt="menu" class="menu-icon">
</button>
<button class="navbar-toggler p-2 rounded w-auto" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse justify-content-end" id="navbarSupportedContent">
<ul>
<li>
<a href="user-premium.html">Premium</a>
</li>
<li>
<a href="artist-main.html">For Artists</a>
</li>
<li class="divider">|</li>
<li>
<a href="user-signup.php" id="signup" style="display: block">Sign Up</a>
</li>
<li class="text-center">
<a href="./scripts/logout.php" id="logout" style="display: none;">Logout</a>
</li>
<li>
<a href="./user-login.php" id="login" style="display: block;">Login</a>
</li>
<?php
if (isset($_SESSION["listener_id"]) || isset($_SESSION["artist_id"])) {
?>
<script>
document.getElementById("signup").style.display = "none";
document.getElementById("logout").style.display = "block";
document.getElementById("login").style.display = "none";
</script>
<?php
}
?>
</ul>
</div>
</nav>
</div>
</div>
<div class="main-container">
<h2 class=" text-white">Settings</h2>
<?php
if (isset($_GET["error"])) {
$error = $_GET["error"];
$msg = "";
if ($error == "0") {
$msg = "Profile updated successfully";
} elseif ($error == "1") {
$msg = "Manadatory fields are left empty. Please try again";
} elseif ($error == "2") {
$msg = "Password does not match";
} elseif ($error == "3") {
$msg = "File type profile picture is not supported (Supported types: .png, .jpeg, .jpg)";
} elseif ($error == "4") {
$msg = "File type cover picture is not supported (Supported types: .png, .jpeg, .jpg)";
} elseif ($error == "5") {
$msg = "Profile picture is larger than max supported limit (5MB)";
} elseif ($error == "6") {
$msg = "Cover picture is larger than max supported limit (5MB)";
} elseif ($error == "7") {
$msg = "Passwords cannot be empty or null";
} elseif ($error == "8") {
$msg = "Wrong password";
}
if ($error == "0") {
?>
<p class="text-success text-center h5 mt-5"><?php echo $msg; ?></p>
<?php
} else {
?>
<p class="text-danger text-center mt-5"><?php echo $msg; ?></p>
<?php
}
}
?>
<?php
$con = DBConnector::getConnection();
// Select the current password for the listener
$selectQuery = "SELECT * FROM listener WHERE listener_id = ?";
$selectStmt = $con->prepare($selectQuery);
$selectStmt->bindValue(1, $_SESSION["listener_id"]);
$selectStmt->execute();
$row = $selectStmt->fetch(PDO::FETCH_ASSOC);
?>
<form class="mx-5 my-5 px-5" action="scripts/process-listener.php" method="post" enctype="multipart/form-data" onsubmit="confirm('Are you sure you want to proceed?')">
<input type="hidden" name="listener_id" id="listener_id" value="<?php echo $_SESSION["listener_id"]; ?>" />
<div class="row">
<h3 class=" text-white mb-4">Edit User details </h3>
</div>
<div class="row">
<div class="col-md-6 mb-3">
<label for="first_name" class="form-label text-white">First Name</label>
<input type="text" name="first_name" class="form-control bg-dark text-white place-holder" value=<?php echo $row['first_name']; ?> id="first_name">
</div>
<div class="col-md-6 mb-3">
<label for="last_name" class="form-label text-white">Last Name</label>
<input type="text" name="last_name" class="form-control bg-dark text-white place-holder" value=<?php echo $row['last_name']; ?> id="last_name">
</div>
<div class="col-md-6 mb-3">
<label for="user_email" class="form-label text-white">Email</label>
<input type="text" name="user_email" class="form-control bg-dark text-white place-holder" value=<?php echo $row['email']; ?> id="user_email">
</div>
<div class="col-md-6 mb-3">
<label for="username" class="form-label text-white">Username</label>
<input type="text" name="username" class="form-control bg-dark text-white place-holder" value=<?php echo $row['username']; ?> id="username">
</div>
<div class="col-md-6 mb-3">
<label for="sub_plan" class="form-label text-white">Subscription Plan</label>
<input type="text" name="sub_plan" class="form-control bg-dark text-white place-holder" placeholder="Subscription Plan" id="sub_plan">
</div>
<div class="col-md-6 mb-3">
<label for="card_number" class="form-label text-white">Credit Card Number</label>
<input type="password" name="card_number" class="form-control bg-dark text-white place-holder" placeholder="Credit Card Number" id="card_number">
</div>
<div class="col-md-6 mb-3">
<label for="expiry_date" class="form-label text-white">Expiry Date</label>
<input type="date" name="expiry_date" class="form-control bg-dark text-white place-holder" placeholder="Expiry Date" id="expiry_date">
</div>
<div class="col-md-6 mb-3">
<input type="hidden" class="form-control bg-dark text-white place-holder">
</div>
<div class="d-flex">
<input type="submit" class="ms-auto btn btn-warning fw-medium px-5 py-2 mt-4 btn-go" value="Save Changes" name="save">
</div>
</form>
</div>
<form class="mx-5 my-5 px-5" action="scripts/process-listener-password.php" method="post" enctype="multipart/form-data" onsubmit="confirm('Are you sure you want to proceed?')">
<input type="hidden" name="listener_id" id="listener_id" value="<?php echo $_SESSION["listener_id"]; ?>" />
<div class="row">
<h3 class=" text-white">Change password </h3><br><br>
</div>
<div class="col-md-6 mb-3">
<label for="current_password" class="form-label text-white">Password</label>
<input type="password" name="current_password" class="form-control bg-dark text-white place-holder" placeholder="Password" id="new_password">
</div>
<div class="col-md-6 mb-3">
<label for="new_password" class="form-label text-white">New Password</label>
<input type="password" name="new_password" class="form-control bg-dark text-white place-holder" placeholder="New Password" id="new_password">
</div>
<div class="col-md-6 mb-3">
<label for="confirm_password" class="form-label text-white">Confirm Password</label>
<input type="password" name="confirm_password" class="form-control bg-dark text-white place-holder" placeholder="Confirm Password" id="confirm_password">
</div>
<div class="d-flex">
<input type="submit" class="ms-auto btn btn-warning fw-medium px-5 py-2 mt-4 btn-go" value="Changes password" name="change_password">
</div>
</form>
</div>
<script src="https://kit.fontawesome.com/23cecef777.js" crossorigin="anonymous"></script>
<script src="js/render-siderbar.js"></script>
<script src="js/render-topbar.js"></script>
</body>
</html>