-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetting.php
196 lines (172 loc) · 5.88 KB
/
setting.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
<?php
if (session_status() === PHP_SESSION_NONE) {
session_start();
}
if (!isset($_SESSION['email'])) {
header('location:adminlogin.php');
exit();
}
$email = $_SESSION['email'];
// Fetch jobseeker data from the database
$conn = new mysqli("localhost", "root", "", "jobportal");
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT * FROM jobseeker WHERE jobseeker_email = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("s", $email);
$stmt->execute();
$result = $stmt->get_result();
if ($result->num_rows > 0) {
$jobseeker = $result->fetch_assoc();
} else {
echo "No user found.";
exit();
}
$errors = [];
$uploadDir = 'uploads/';
$allowedImageTypes = ['image/jpeg', 'image/png'];
$allowedCvTypes = ['application/pdf'];
$maxImageSize = 524288000; // 500MB
$maxCvSize = 1048576; // 1MB
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (isset($_POST['update_info'])) {
$field = $_POST['field'];
if (isset($_POST['value'])) {
$value = $_POST['value'];
} else {
$value = '';
}
if ($field == 'password') {
$oldPassword = $_POST['oldPassword'];
$newPassword = $_POST['newPassword'];
$confirmPassword = $_POST['confirmPassword'];
if ($oldPassword != $jobseeker['password']) {
$errors['password'] = 'Old password is incorrect.';
} elseif ($newPassword != $confirmPassword) {
$errors['password'] = 'New passwords do not match.';
} else {
$value = $newPassword; // No hashing
$field = 'password';
}
}
if (empty($errors)) {
$sql = "UPDATE jobseeker SET $field = ? WHERE jobseeker_email = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("ss", $value, $email);
if ($stmt->execute()) {
header("Location: Setting.php");
exit();
} else {
$errors['update'] = 'Failed to update information.';
}
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Responsive Profile Page</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css"/>
<link rel="stylesheet" href="profile.css">
<link rel="stylesheet" href="style.css">
<style>
.file-input-wrapper {
position: relative;
display: inline-block;
}
.file-input-wrapper input[type="file"] {
position: absolute;
left: 0;
top: 0;
opacity: 0;
width: 100%;
height: 100%;
cursor: pointer;
}
.file-input-wrapper span {
display: inline-block;
padding: 8px 16px;
background-color: #338573;
color: #fff;
border-radius: 4px;
cursor: pointer;
transition: background-color 0.3s ease;
}
.file-input-wrapper span:hover {
background-color: #45a049;
}
.update-form {
display: none;
margin-top: 10px;
}
.update-form.active {
display: block;
}
.update {
margin-top: 10px;
}
</style>
</head>
<body>
<?php include 'header.php';?>
<div class="form-group" id="password-group">
<label>Change Password:</label>
<button class="edit-icon" onclick="toggleEdit('password')"><img src="Images/edit-text.png" alt=""></button>
<div class="update-form" id="update-password">
<form action="Setting.php" method="post">
<input type="hidden" name="field" value="password">
<input type="password" name="oldPassword" placeholder="Old Password">
<input type="password" name="newPassword" placeholder="New Password">
<input type="password" name="confirmPassword" placeholder="Confirm Password">
<button type="submit" name="update_info">Update</button>
</form>
</div>
</div>
<footer id="footer">
<div class="footer-content">
<div class="logo">
<h2>Job Portal</h2>
</div>
<div class="socail-links">
<i class="fa-brands fa-twitter"></i>
<i class="fa-brands fa-facebook-f"></i>
<i class="fa-brands fa-instagram"></i>
<i class="fa-brands fa-youtube"></i>
<i class="fa-brands fa-pinterest-p"></i>
</div>
</div>
<div class="footer-bottom-content">
<p>Designed By Job Portal teams</p>
<div class="copyright">
<p>©Copyright <strong>Job portal</strong>.All Rights Reserved</p>
</div>
</div>
</footer>
<script>
document.getElementById("fileImg").onchange = function() {
document.getElementById("image").src = URL.createObjectURL(fileImg.files[0]); // Preview new image
document.getElementById("cancel").style.display = "block";
document.getElementById("confirm").style.display = "block";
document.getElementById("upload").style.display = "none";
}
var userImage = document.getElementById('image').src;
document.getElementById("cancel").onclick = function() {
document.getElementById("image").src = userImage; // Back to previous image
document.getElementById("cancel").style.display = "none";
document.getElementById("confirm").style.display = "none";
document.getElementById("upload").style.display = "block";
}
function toggleEdit(id) {
var form = document.getElementById('update-' + id);
if (form) {
form.classList.toggle('active');
}
}
</script>
</body>
</html>