-
Notifications
You must be signed in to change notification settings - Fork 5
/
cust_pwd.php
150 lines (135 loc) · 4.42 KB
/
cust_pwd.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
<?php
session_start();
if(!isset($_SESSION["CUS_ID"])){
header("location:index.php");
}
include("db.php");
include("includes/header.php");
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/login.css">
<link rel="stylesheet" type="text/css" href="css/cat_card.css">
<link rel="stylesheet" type="text/css" href="css/font.scss">
<title>Change password</title>
<style>
body{
background-image: url("images/sky.gif");
background-size: cover;
}
</style>
<script type="text/javascript">
function check()
{
if (document.getElementById('newpwd').value ==
document.getElementById('cnfmpwd').value)
{
document.getElementById('message').style.color = 'lime';
document.getElementById('message').innerHTML = 'matching';
}
else
{
document.getElementById('message').style.color = 'tomato';
document.getElementById('message').innerHTML = 'not matching';
}
}
function CheckPassword()
{
var decimal= /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9])(?!.*\s).{6,}$/;
if(document.getElementById('newpwd').value.match(decimal))
{
document.getElementById('pwdmessage').style.color = 'lime';
document.getElementById('pwdmessage').innerHTML = 'Valid Password';
}
else
{
document.getElementById('pwdmessage').style.color = 'tomato';
document.getElementById('pwdmessage').innerHTML = 'Should contain minimum 8 characters with at least a numeric, uppercase ,lowercase and special character';
}
}
function disfunc()
{
if(document.getElementById('message').style.color == 'lime' &&
document.getElementById('pwdmessage').style.color == 'lime')
{
document.getElementById("reset").removeAttribute("disabled");
}
else{
document.getElementById("reset").setAttribute("disabled", "disabled");
}
}
</script>
</head>
<body>
<div class="login-box" style="margin: auto">
<h2>Change Password</h2>
<form action="<?php echo $_SERVER["PHP_SELF"];?>" method="post">
<hr><br>
<?php
if (isset($_POST["reset"]))
{
$_POST['oldpwd'] = addslashes($_POST['oldpwd']);
$_POST['newpwd'] = addslashes($_POST['newpwd']);
$_POST['cnfmpwd'] = addslashes($_POST['cnfmpwd']);
$sql1 = "SELECT * FROM customer where cus_pass = '{$_POST['oldpwd']}' and cus_id = '{$_SESSION['CUS_ID']}'";
$res1 = $db->query($sql1);
if ($res1->num_rows == 0)
{
echo "<p style='color:tomato;'>Incorrect old password</p>";
}
else if ($_POST["newpwd"] != $_POST["cnfmpwd"])
{
echo "<p style='color:tomato;'>Enter confirm password properly !</p>";
}
else if ($_POST["oldpwd"] == $_POST["newpwd"])
{
echo "<p style='color:tomato;'>New password should not be same !</p>";
}
else
{
$sql = "UPDATE customer set cus_pass = '{$_POST['newpwd']}' where cus_id = '{$_SESSION['CUS_ID']}'";
$res = $db->query($sql);
if ($res)
{
echo "<p style='color:lime;'>Password Updated Successfully</p>";
}
else
{
echo "<p style='color:tomato;'>Password Update failed !</p>";
}
}
}
?>
<div class="user-box">
<input type="password" name="oldpwd" required>
<label>Old Password</label>
</div>
<div class="user-box">
<input type="password" name="newpwd" id="newpwd" onkeyup="CheckPassword(); check(); disfunc()" required>
<label>New Password</label>
<i><div id="message" style="float: right;"></div><i>
</div>
<div class="user-box">
<input type="password" name="cnfmpwd" id="cnfmpwd" onkeyup="check(); disfunc()" required>
<label>Confirm Password</label>
</div>
<i><div id="pwdmessage"></div><i>
<br>
<a>
<button type="submit" class="resetpwd" id="reset" name="reset" style="color: white; font-size: 100%; font-family: inherit; border: none; padding: 0!important; background: none!important; cursor: pointer;">
<span></span>
<span></span>
Reset Password
</button>
</a>
</form>
</div>
<style>
#pwd{
background: #8ae600;
}
#pwd:after{
color: #8ae600;
}
</style>