-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchange_pincode.php
193 lines (152 loc) · 5.75 KB
/
change_pincode.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
<?php include ('inc_meta_header.php'); ?>
<title>
<?php
$page_link_url = basename($_SERVER['PHP_SELF']);
$plu_del_ext = rtrim($page_link_url, ' .php');
echo $plu_del_rep = ucwords(str_replace("_", " ", $plu_del_ext));
?>
<?php include ('inc_page_title.php'); ?>
</title>
<?php include ('inc_head.php'); ?>
<!--- Password Confirm Script --->
<script language="javascript">
<!--
function verify(form)
{
var val,errorstr="";
//check for catname
if (form.nspwd.value!=form.cnspwd.value){errorstr=errorstr+"\n Confirm New Password and New Password should have same values !" ;}
if(errorstr!="")
{
alert(errorstr);
return false ;
}
else
{
//form.submit();
return (true);
}
}
//-->
</script>
<!--- Password Confirm Script End --->
<?php
//errors--------------
$updated = '';
if(isset($_GET['updated'])) {
$updated=$_GET['updated'];
if($updated=='y') {
$updated = 'Your pin is successfully updated!';
}
}
//--------------------
?>
<?php
$str = "";
if (isset($_POST['submit'])) {
$oldpwd = $_POST['spwd'];
$newpwd = $_POST['nspwd'];
$oldpwdHash = md5($oldpwd);
$result_change_password = mysqli_query($link, "SELECT PWPIN, ID FROM `admin` WHERE ID = '$EMPLOYEEID_LOGIN'");
while($row_change_password = mysqli_fetch_array($result_change_password))
{
$dbpwdHash= $row_change_password['PWPIN'];
}
if ($oldpwdHash == $dbpwdHash || $dbpwdHash == '' )
{
$newpwdHash = md5($newpwd);
$sql="UPDATE `admin` SET PWPIN='$newpwdHash' WHERE ID = '$EMPLOYEEID_LOGIN'";
if(!mysqli_query($link, $sql)){
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
$str = '
<div class="col-lg-8 col-lg-offset-2">
<div class="alert alert-success al-center">Your Password has been changed!</div>
</div>
';
}
else
{
$str = '
<div class="col-lg-8 col-lg-offset-2">
<div class="alert alert-warning al-center">Old Password is invalid!</div>
</div>
';
}
}
?>
<body class="nav-md">
<div class="container body">
<div class="main_container">
<div class="col-md-3 left_col">
<?php include ('inc_nav.php'); ?>
</div>
<?php include ('inc_header.php'); ?>
<!-- breadcrumb -->
<div class="breadcrumb_content">
<div class="breadcrumb_text"><a href="dashboard.php">Dashboard</a> / <?php echo $plu_del_rep; ?>
</div>
</div>
<!-- /breadcrumb -->
<!-- page content -->
<div class="right_col" role="main">
<div class="">
<div class="page-title">
<div class="title_left">
<h3><?php echo $plu_del_rep; ?></h3>
</div>
</div>
<div class="clearfix"></div>
<div class="row">
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="x_panel">
<div class="x_title">
<h4><?php echo $plu_del_rep; ?></h4>
<div class="clearfix"></div>
</div>
<div class="x_content">
<div id="form-content">
<?php echo $str; ?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="form" onSubmit="return verify(this);">
<div class="container">
<div class="row sml-padding">
<div class="col-lg-3 col-lg-offset-2"><label>Current Pincode <span class="text-danger"></span></label></div>
<div class="col-lg-5">
<input class="form-control" name="spwd" type="password">
<span class="text-muted"> <i class="fa fa-info-circle"></i> <em>Leave blank if you're generating first time.</em></span>
</div>
</div>
<div class="row sml-padding">
<div class="col-lg-3 col-lg-offset-2">
<label>New Pincode <span class="text-danger">*</span></label>
</div>
<div class="col-lg-5">
<input class="form-control" name="nspwd" type="password" required>
</div>
</div>
<div class="row sml-padding">
<div class="col-lg-3 col-lg-offset-2"><label>Repeat Pincode <span class="text-danger">*</span></label></div>
<div class="col-lg-5">
<input class="form-control" name="cnspwd" type="password" required>
</div>
</div>
<div class="row sml-padding">
<div class="col-lg-3 col-lg-offset-2"> </div>
<div class="col-lg-5">
<input name="submit" type="submit" class="btn btn-primary" value="Update Pincode">
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- /page content -->
<?php include ('inc_footer.php'); ?>
</div>
</div>
<?php include ('inc_foot.php'); ?>