-
Notifications
You must be signed in to change notification settings - Fork 10
/
changepass.php
127 lines (113 loc) · 3.55 KB
/
changepass.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
<?php
include("sqlcon.php");
if(isset($_POST[update]))
{
if(isset($_SESSION['type']))
{
if($_SESSION['type'] == "alumni")
{
$rs = mysqli_query($con,"update tbluser set upass=".$_POST[newpass]." where userid=".$_SESSION['uid']);
if($rs)
{
echo "<script>alert(Password Updated!!);</script>";
}
}
else if($_SESSION['type'] == "admin")
{
$rs1 = mysqli_query($con,"update tbladmin set apassword=".$_POST[newpass]." where adminid=".$_SESSION['uid']);
if($rs1)
{
echo "<script>alert(Password Updated!!);</script>";
}
}
else if($_SESSION['type'] == "staff")
{
$rs2 = mysqli_query($con,"update tblstaff set staff_pass=".$_POST[newpass]." where staffid=".$_SESSION['uid']);
if($rs2)
{
echo "<script>alert(Password Updated!!);</script>";
}
}
}
else
{
echo "<script>alert(Please login !!);window.location=index.php;</script>";
}
}
/* ### */ ?>
<?php
include("header.php")
/* ### */ ?>
<div class="container">
<div class="page">
<h3 align="center" >Change Password</h3>
<div class="bs-example" data-example-id="simple-horizontal-form">
<form action="" method="post" class="form-horizontal">
<div class="form-group">
<label for="inputEmail3" class="col-sm-4 control-label" style="text-align:right;">Current Password</label>
<div class="col-sm-4">
<input type="password" class="form-control" id="curpass" name="curpass" placeholder="Current Password" required onchange="checkpass(this.value)">
</div>
</div>
<div class="form-group">
<label for="inputEmail3" class="col-sm-4 control-label" style="text-align:right;">New Password</label>
<div class="col-sm-4">
<input type="password" class="form-control" id="newpass" name="newpass" placeholder="Password" required>
</div>
</div>
<div class="form-group">
<label for="inputEmail3" class="col-sm-4 control-label" style="text-align:right;">Retype Password</label>
<div class="col-sm-4">
<input type="password" class="form-control" id="retypepass" name="retypepass" placeholder="Password" required>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-8" style="text-align:center;">
<input type="submit" name="update" value="UPDATE" class="btn btn-default" onclick="isPasswordMatch()"/>
<input type="reset" name="cancel" value="CANCEL" class="btn btn-default"/>
</div>
</div>
</form>
</div>
</div>
</div>
<?php
include("footer.php")
/* ### */ ?>
<script>
function checkpass(pass)
{
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else {
// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
if(xmlhttp.responseText.trim() =="error")
{
alert("invalid current password");
document.getElementById("curpass").value="";
document.getElementById("curpass").focus();
}
}
}
var getlink = "ajaxsetup.php?p="+pass;
xmlhttp.open("GET",getlink,true);
xmlhttp.send();
}
function isPasswordMatch() {
var password = document.getElementById("newpass");
var confirm_password = document.getElementById("retypepass");
if(password.value != confirm_password.value)
{
confirm_password.setCustomValidity("Passwords Dont Match");
}
else
{
confirm_password.setCustomValidity();
}
}
</script>