-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsettings.php
More file actions
203 lines (187 loc) · 7.91 KB
/
settings.php
File metadata and controls
203 lines (187 loc) · 7.91 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
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
<?php
// error handling
error_reporting(E_ALL);
ini_set('display_errors', 1);
session_start();
include("connection.php");
include("phpfunctions.php");
// check if user is logged in
if(isset($_SESSION['pfType']))
{
$user = checkLogin($conn, $_SESSION['pfType']);
$submission_stage = $user->stage;
$verifiedFlag = false;
// check if user is verified
if ($submission_stage == 'Approved')
{
$verifiedFlag = true;
}
}
// check if the form is submitted
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
// check if save changes button is clicked
if (isset($_POST["saveChanges"]))
{
// Get the form data and sanitize/validate it (not implemented here)
$firstName = $_POST["firstName"];
$lastName = $_POST["lastName"];
$email = $_POST["email"];
$birthday = $_POST["birthday"];
$phoneNumber = $_POST["phone-number"];
// change name, email, and birth
$user->changeName($conn, $firstName, $lastName);
$user->changeEmail($conn, $email);
$user->changeBirth($conn, $birthday);
// check if user has no phone number
if ($user->phone == "No Phone Number")
{
//insert the phone number in the 'user_phone_numbers' table with FK: user id
$query = "INSERT INTO user_phone_numbers (user_id, phone_number) VALUES (:user_id, :phone_number)";
$query_run = $conn->prepare($query);
$query_run->execute(array(':phone_number' => $phoneNumber, ':user_id' => $user->user_id));
}
// else user has a phone number and wants to change it
else
{
$user->changeNumber($conn, $phoneNumber);
}
// profile picture upload
if (isset($_FILES["profilePictureFile"]) && $_FILES["profilePictureFile"]["error"] == 0)
{
// File path and where to put it
$targetDir = "upload/";
$fileName = basename($_FILES["profilePictureFile"]["name"]);
$targetFilePath = $targetDir . $fileName;
// Move the file into path
if (move_uploaded_file($_FILES["profilePictureFile"]["tmp_name"], $targetFilePath))
{
// Insert file path into the profile_pictures table
$query = "INSERT INTO profile_pictures (user_id, file_path) VALUES (:userId, :filePath)";
$stmt = $conn->prepare($query);
$stmt->execute(array(':userId' => $user->user_id, ':filePath' => $targetFilePath));
// Redirect to the profile page with success message
header("Location: nurse-profile.php?success=1");
exit();
}
else
{
// Error handling: Profile picture upload failed
echo "Sorry, there was an error uploading your profile picture.";
}
}
// Redirect to the profile page after saving changes
header("Location: nurse-profile.php");
exit();
}
}
?>
<!-- Nurse profile header -->
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Meta tags -->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Title -->
<title>Nurse Setttings
</title>
<!-- CSS links -->
<link rel="stylesheet" href="style/generalStyle.css">
<style>
#setting-tab{
background-color: #e7b93b;
color: #fff;
}
</style>
<!-- JavaScript links -->
<!-- Font Awesome links for the Footer Icons -->
<script src="https://kit.fontawesome.com/c011338aa2.js" crossorigin="anonymous"></script>
<!-- JavaScript for the navigation bar -->
<script src="script.js" defer>
</script>
</head>
<!-- Body of the page -->
<body>
<!-- Top of the page -->
<?php include('header.php'); ?>
<!----- FORM ---->
<div class="profile-container">
<div class = "profile-content">
<!-- Profile header -->
<div class="profile-header">
<!-- Profile picture -->
<h1 id="profile-Title">User Profile</h1>
<!-- Profile name -->
<div class="profile-picture">
<?php
$profile_picture_path = "get-pfp.php";
echo "<img src='$profile_picture_path' alt='Profile Picture'>";
?>
</div>
<?php
echo "<h2 class='name-info'><strong>$user->first_name $user->last_name";
// Display the verified icon if the user is verified
if ($verifiedFlag)
{
echo "<img src='images/icons/check-symbol.png' class='verified-icon'>";
}
// Close the strong tag
echo "</strong></h2>";
?>
</div>
<!-- Profile data -->
<div class="profile-data">
<!-- Move the form and profile picture div here -->
<!--on the left will have tabs for payment to update the screen -->
<div class = "profile-nav">
<div class="profile-tabs">
<li ><a href="nurse-profile.php" class="active">Profile</a></li>
<!-- These links will be updated to the correct pages -->
<li><a href="">Payment</a></li>
<li><a href = "" >History</a></li>
<li><a id="setting-tab" href="settings.php">Settings</a></li>
</div>
</div>
<!-- Profile information -->
<div class="profile-info">
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>">
<div class="form-group">
<label for="firstName">First Name</label>
<input type="text" id="firstName" name="firstName" value="<?php echo $user->first_name; ?>">
</div>
<div class="form-group">
<label for="lastName">Last Name</label>
<input type="text" id="lastName" name="lastName" value="<?php echo $user->last_name; ?>">
</div>
<div class="form-group">
<label for="email">Email</label>
<input type="email" id="email" name="email" value="<?php echo $user->email; ?>">
</div>
<div class="form-group">
<label for="birthday">Birthday</label>
<input type="date" id="birthday" name="birthday" value="<?php echo $user->birthday; ?>">
</div>
<div class="form-group">
<label for="password">Phone Number</label>
<input type="text" id="phone-number" name="phone-number" value="<?php echo $user->phone; ?>">
</div>
<button class="sub-btn" type="submit" name="saveChanges">Save Changes</button>
<button class="sub-btn" type="button" onclick="cancelChanges()">Cancel</button>
</form>
</div>
<div id = "certification">
<form id="pfpForm" action="upload-pfp.php" method="post" enctype="multipart/form-data">
<div class="pfp-upload">
<h2>Upload Profile Photo</h2>
</div>
<label for="profilePictureFile" class="select-btn">Select Photo</label>
<input type="file" id="profilePictureFile" name="profilePictureFile" accept="image/*" class="file-input">
<button type="submit" class="upload-btn">Upload</button>
<span id='fileNameDisplay' class='file-name-display'>$inputFileName</span>
</form>
</div>
</div>
</div>
</div>
</body>
</html>