-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathchange-password.php
75 lines (72 loc) · 2.71 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
session_start();
include('includes/dbconnection.php');
error_reporting(0);
if (strlen($_SESSION['sessionid']==0))
{
header('location:logout.php');
}
else
{
if(isset($_POST['change_pass']))
{
$userid=$_SESSION['sessionid'];
$cpassword=md5($_POST['currentpassword']);
$newpassword=md5($_POST['newpassword']);
$query=mysqli_query($con,"SELECT ID FROM tbluser WHERE ID='$userid' AND Password='$cpassword'");
$row=mysqli_fetch_array($query);
if($row>0)
{
$ret=mysqli_query($con,"UPDATE tbluser SET Password='$newpassword' WHERE ID='$userid'");
$msg= "Your password successully changed";
}
else
{
$msg="Your current password is wrong";
}
}
?>
<script type="text/javascript">
function checkpass()
{
if(document.changepassword.newpassword.value!=document.changepassword.confirmpassword.value)
{
alert('New Password and Confirm Password field does not match');
document.changepassword.confirmpassword.focus();
return false;
}
return true;
}
</script>
<?php include 'includes/header.php';?>
<div class="main-content">
<div class="title">
Change Password
</div>
<div class="main">
<div class="form-container">
<p style="font-size:16px; color:red" align="center"> <?php if($msg){echo $msg;} ?> </p>
<form role="form" method="post" action="" name="changepassword" onsubmit="return checkpass();">
<p class="form-title">Change Your Password</p>
<div class="item">
<label for="current">Current Password:</label>
<input type="password" name="currentpassword" class="input" required>
</div>
<div class="item">
<label for="new">New Password:</label>
<input type="password" name="newpassword" class="input" required>
</div>
<div class="item">
<label for="confirm">Confirm Password:</label>
<input type="password"class="input" required>
</div>
<div class="btn-block">
<button type="submit" value="Submit" class="input button" name="change_pass">Change</button> `
</div>
</form>
</div>
</div>
</div>
<?php include_once('includes/footer.php');?>
<?php
}?>