-
Notifications
You must be signed in to change notification settings - Fork 0
/
changepassworduser.php
106 lines (102 loc) · 3.57 KB
/
changepassworduser.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
<?php
include("header.php");
if($_SESSION[sessionid] == $_POST[sessionid])
{
if(isset($_POST[submit]))
{
$ectopass=md5($_POST[oldpassword]);
$ectnpass=md5($_POST[newpassword]);
$sql="UPDATE user SET password=$ectnpass WHERE password=$ectopass AND user_id=$_SESSION[user_id] ";
$qsql = mysqli_query($con,$sql);
echo mysqli_error($con);
if(mysqli_affected_rows($con) == 1)
{
echo "<SCRIPT>alert(Password updated successfully.);</SCRIPT>";
echo "<script>window.location=dashboard.php;</script>";
}
else
{
echo "<SCRIPT>alert(Failed to update password...);</SCRIPT>";
}
}
}
$_SESSION[sessionid] = rand();
?>
<section id="contentSection">
<div class="row">
<div class="col-lg-8 col-md-8 col-sm-8">
<div class="left_content">
<div class="contact_area">
<h2>Change Password</h2>
<p>You can change password here.</p>
<form action="" class="contact_form" method="post" name="frmchangepassworduser" onsubmit="return validateform()">
<input type="hidden" name="sessionid" value="<?php echo $_SESSION[sessionid]; ?>" >
Old Password:
<input name="oldpassword" class="form-control" type="password" placeholder="Old Password *">
<span id="idoldpassword"></span>
<br>
New Password:
<input name="newpassword" class="form-control" type="password" placeholder="New Password *">
<span id="idnewpassword"></span>
<br>
Confirm Password:
<input name="confirmpassword" class="form-control" type="password" placeholder="Confirm Password *">
<span id="idconfirmpassword"></span>
<br>
<input name="submit" type="submit" value="Submit">
</form>
</div>
</div>
</div>
</div>
</section>
<?php
include("footer.php")
?>
<script type="application/javascript">
function validateform()
{
var validatecondtion = 0;
document.getElementById("idoldpassword").innerHTML ="";
document.getElementById("idnewpassword").innerHTML ="";
document.getElementById("idconfirmpassword").innerHTML ="";
if(document.frmchangepassworduser.oldpassword.value.length < 8)
{
document.getElementById("idoldpassword").innerHTML ="<font color=red>Password must contain at least 8 characters..</font>";
validatecondtion=1;
}
if(document.frmchangepassworduser.oldpassword.value=="")
{
document.getElementById("idoldpassword").innerHTML ="<font color=red>Kindly enter Old Password....</font>";
validatecondtion=1;
}
if(document.frmchangepassworduser.newpassword.value.length < 8)
{
document.getElementById("idnewpassword").innerHTML ="<font color=red>Password must contain at least 8 characters..</font>";
validatecondtion=1;
}
if(document.frmchangepassworduser.newpassword.value=="")
{
document.getElementById("idnewpassword").innerHTML ="<font color=red>Password should not be empty..</font>";
validatecondtion=1;
}
if(document.frmchangepassworduser.newpassword.value!=document.frmchangepassworduser.confirmpassword.value)
{
document.getElementById("idconfirmpassword").innerHTML ="<font color=red>Password and Confirm password are not matching..</font>";
validatecondtion=1;
}
if(document.frmchangepassworduser.confirmpassword.value=="")
{
document.getElementById("idconfirmpassword").innerHTML ="<font color=red>Confirm Password should not be empty..</font>";
validatecondtion=1;
}
if(validatecondtion==1)
{
return false;
}
else
{
return true;
}
}
</script>