-
Notifications
You must be signed in to change notification settings - Fork 0
/
change-password.php
54 lines (50 loc) · 2.09 KB
/
change-password.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
<?php
session_start();
if (!isset($_SESSION['loggedin'])) {
header('Location: index.php');
}
if (isset($_POST['pwd1'])) {
$pwd1 = trim($_POST['pwd1']);
$pwd2 = trim($_POST['pwd2']);
date_default_timezone_set('Asia/Kolkata');
$curr_date = date('Y-m-d H:i:s');
if (($pwd1 != $pwd2) or $pwd1 == "") {
echo "<script> alert('Both passwords not matched') </script>";
} else {
$user = file_get_contents("data/user.json");
$user = json_decode($user, true);
$user["password"] = $pwd1;
file_put_contents("data/user.json", json_encode($user));
session_destroy();
echo "<script> alert('Password changed successfully! ') </script>";
}
}
?>
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-wEmeIV1mKuiNpC+IOBjI7aAzPcEZeedi5yW5f2yOq55WWLwNGmvvx4Um1vskeMj0" crossorigin="anonymous">
<title>Change Password</title>
</head>
<body>
<?php include "header.php" ?>
<center>
<form method="POST" class="mt-5" style="width: 220px" action="change-password.php">
<div></div>
<div class=" mb-3">
<input required placeholder="Enter new password" type="password" class="form-control" id="pwd1" name="pwd1">
</div>
<div class="mb-3">
<input required placeholder="Enter new password again" type="password" class="form-control" id="pwd2" name="pwd2">
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</center>
<!-- Option 1: Bootstrap Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-p34f1UUtsS3wqzfto5wAAmdvj+osOnFyQFpp4Ua3gs/ZVWx6oOypYoCJhGGScy+8" crossorigin="anonymous"></script>
</body>
</html>