-
Notifications
You must be signed in to change notification settings - Fork 13
/
pass_change_action.php
124 lines (93 loc) · 3 KB
/
pass_change_action.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
<?php
include "validate_customer.php";
include "header.php";
include "customer_navbar.php";
include "customer_sidebar.php";
include "session_timeout.php";
/* Set appropriate error number if errors are encountered.
Key (for err_no) :
-1 = Connection Error.
0 = Successful Change.
1 = Old password is incorrect.
2 = Passwords do not match.
3 = Old and new passwords are same. */
$err_no = -1;
$id = $_SESSION['loggedIn_cust_id'];
$type = mysqli_real_escape_string($conn, $_POST["type"]);
$old_pwd = mysqli_real_escape_string($conn, $_POST["old_pwd"]);
$new_pwd = mysqli_real_escape_string($conn, $_POST["new_pwd"]);
$check_pwd = mysqli_real_escape_string($conn, $_POST["check_pwd"]);
if ($type == "password") {
$sql0 = "SELECT * FROM customer WHERE cust_id=".$id." AND pwd='".$old_pwd."'";
$info_string = "Password";
}
if ($type == "pin") {
$sql0 = "SELECT * FROM customer WHERE cust_id=".$id." AND pin='".$old_pwd."'";
$info_string = "PIN";
}
$result0 = $conn->query($sql0);
if (($result0->num_rows) > 0) {
if ($new_pwd == $check_pwd) {
if ($new_pwd != $old_pwd) {
if ($type == "password") {
$sql1 = "UPDATE customer SET pwd = '$new_pwd' WHERE cust_id=".$id;
}
if ($type == "pin") {
$sql1 = "UPDATE customer SET pin = '$new_pwd' WHERE cust_id=".$id;
}
if (($conn->query($sql1) === TRUE)) {
$err_no = 0;
}
}
else {
$err_no = 3;
}
}
else {
$err_no = 2;
}
}
else {
$err_no = 1;
}
?>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="action_style.css">
</head>
<body>
<div class="flex-container">
<div class="flex-item">
<?php
if ($err_no == -1) { ?>
<p id="info"><?php echo "Connection Error ! Please try again later.\n"; ?></p>
<?php } ?>
<?php
if ($err_no == 0) { ?>
<p id="info"><?php echo $info_string." successfully changed !\n";
?></p>
<?php } ?>
<?php
if ($err_no == 1) { ?>
<p id="info"><?php echo "Old ".$info_string." is incorrect !\n";
?></p>
<?php } ?>
<?php
if ($err_no == 2) { ?>
<p id="info"><?php echo $info_string."s do not match !\n";
?></p>
<?php } ?>
<?php
if ($err_no == 3) { ?>
<p id="info"><?php echo "Old & new ".$info_string."s are same !\n";
?></p>
<?php } ?>
</div>
<div class="flex-item">
<a href="customer_profile.php" class="button">Go Back</a>
</div>
</div>
</body>
</html>