Repository navigation
Expand file tree
/
Copy pathupdatePassword.php
More file actions
56 lines (49 loc) · 1.78 KB
/
Copy pathupdatePassword.php
File metadata and controls
56 lines (49 loc) · 1.78 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
<?php
require "./db_connection.php"; // Make sure the database connection file is correctly included
$useremail = $_COOKIE['passwordupdatestate'];
echo $useremail;
setcookie('otp', '', time() - 3600, '/');
if(isset($_COOKIE['passwordupdatestate'])){
echo "om";
setcookie('passwordupdatestate',false);
if ($_SERVER["REQUEST_METHOD"] === "POST") {
if (isset($_POST['update_password'])) {
// Check if the 'useremail' cookie is set
// $useremail = $_COOKIE['useremail'];
$newpassword = $_POST['newpassword'];
$updateQuery = "UPDATE Employee SET Password = ? WHERE Email = ?";
$stmt = $conn->prepare($updateQuery);
if ($stmt) {
// Bind the parameters
$stmt->bind_param("ss", $newpassword, $useremail);
// Execute the query
if ($stmt->execute()) {
echo "Password updated successfully.";
header("Location: index.php"); // Redirect to the home page
} else {
echo "Error updating password: " . $stmt->error;
}
$stmt->close();
} else {
echo "Error preparing the statement: " . $conn->error;
}
}
}
}
else{
echo "salunke";
header("Location:ForgotPass.php");
}
?>
<!DOCTYPE html>
<html>
<body>
<form method="post" action="updatePassword.php">
<input type="password" name="newpassword" placeholder="Enter new password" required>
<button name="update_password" type="submit">Update Password</button>
</form>
</body>
<script>
document.cookie="";
</script>
</html>