-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.php
153 lines (141 loc) · 7.28 KB
/
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
<!DOCTYPE html>
<html lang="en">
<?php
require('connect-db.php');
session_start();
$username = $_SESSION['user'];
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (!empty($_POST['action'])) {
$username = $_SESSION['user'];
$theme = $_POST['action'];
$query = "UPDATE settings SET theme=:theme WHERE username=:username";
$statement = $db->prepare($query);
$statement->bindValue(':theme', $theme);
$statement->bindValue(':username', $username);
$statement->execute();
$statement->closeCursor();
}
}
?>
<head>
<link rel="apple-touch-icon" sizes="180x180" href="icon/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="icon/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="icon/favicon-16x16.png">
<link rel="manifest" href="icon/site.webmanifest">
<!-- FONT -->
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Rubik:wght@300&display=swap" rel="stylesheet">
<!-- <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.0/css/all.css" integrity="sha384-lZN37f5QGtY3VHgisS14W3ExzMWZxybE1SJSEsQp9S+oqd12jhcu+A56Ebc1zFSJ" crossorigin="anonymous"> -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<script src="https://kit.fontawesome.com/a076d05399.js"></script>
<link rel="stylesheet" href="./themes/purple.css" type="text/css" />
<link rel="stylesheet" id="switcher-id" href="">
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="author" content="Vivian Tran vt5en & Valerie Young vy5br">
<meta name="description" content="POTD 1">
<title>queueAble: Finding Time for What's Important</title>
</head>
<?php include('navbar.php')?>
<body>
<div class="jumbotron">
<center>
<h1>Settings</h1>
</center>
</div>
<div class="container">
<div class="row">
<div class="col">
<h2>Password</h2>
<form class="needs-validation" id ="changepassword" name="changepassword" action="changep.php" method="POST">
<input id="currentPassword" name="currentPassword" type="password" placeholder="Enter Current Password" type="text" required> <!-- need to put in a validation message if empty -->
<p></p>
<input id="newPassword" name="newPassword" type="password" placeholder="Enter New Password" type="text" required>
<p></p>
<input id="confirmPassword" name="confirmPassword" type="password" placeholder="Confirm New Password" type="text" required>
<button class="btn" type="submit" onclick="">Change Password</button>
</form>
</div>
<div class="col">
<h2>Email</h2>
<form class="needs-validation" id ="changeemail" name="changeemail" action="changee.php" method="POST">
<input id="old-email" type="text" placeholder="Enter Old Email" required> <!-- need to put in a validation message if empty -->
<p></p>
<input id="newEmail" name="newEmail" type="text" placeholder="Enter Email Again" required>
<p></p>
<input id="confirm-email" type="text" placeholder="Confirm New Email" required>
<button class="btn" type="submit" onclick="">Change Email</button>
</form>
<script type="text/javascript" src="js/script.js"></script>
<script>
// Example starter JavaScript for disabling form submissions if there are invalid fields
(function() {
'use strict';
window.addEventListener('load', function() {
// Fetch all the forms we want to apply custom Bootstrap validation styles to
var forms = document.getElementsByClassName('needs-validation');
// Loop over them and prevent submission
var validation = Array.prototype.filter.call(forms, function(form) {
form.addEventListener('submit', function(event) {
if (form.checkValidity() === false) {
event.preventDefault();
event.stopPropagation();
}
form.classList.add('was-validated');
}, false);
});
}, false);
})();
</script>
</div>
<div class="col">
<h2>Theme Selector</h2>
<div class="theme-switches">
<form action="<?php htmlspecialchars($_SERVER["PHP_SELF"])?>" method="post">
<input type="submit" class="switch-1" id="switch-1" method="POST" name="action" value="light"></input>
<input type="submit" class="switch-2" id="switch-2" method="POST" name="action" value="sky"></input>
<input type="submit" class="switch-3" id="switch-3" method="POST" name="action" value="purple"></input>
<input type="submit" class="switch-4" id="switch-4" method="POST" name="action" value="dark"></input>
<!-- <input type="submit"> -->
</form>
</div>
</div>
</div>
</div>
<?php
$query = "SELECT * FROM settings WHERE username=:username";
$statement = $db->prepare($query);
$statement->bindParam(':username', $username);
$statement->execute();
$settings_info = $statement->fetchAll();
$theme = $statement->fetchAll();
$statement->closecursor();
foreach ($settings_info as $row) {
$theme = $row['theme'];
if ($theme == "light"){
echo "<script>";
echo "document.getElementById('switcher-id').href = './themes/light.css';";
echo "</script>";
}
if ($theme == "sky"){
echo "<script>";
echo "document.getElementById('switcher-id').href = './themes/sky.css';";
echo "</script>";
}
if ($theme == "purple"){
echo "<script>";
echo "document.getElementById('switcher-id').href = './themes/purple.css';";
echo "</script>";
}
if ($theme == "dark"){
echo "<script>";
echo "document.getElementById('switcher-id').href = './themes/dark.css';";
echo "</script>";
}
}
?>
<script type="text/javascript" src="js/script.js"></script>
</body>
<?php include('./footer.php'); ?>
</html>