-
Notifications
You must be signed in to change notification settings - Fork 0
/
chngpswrd.php
217 lines (204 loc) · 5.75 KB
/
chngpswrd.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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
<?php
session_start();
include("includes/header.php");
include("includes/conn.php");
if(isset($_POST["submit"]))
{
if($_SESSION["logtype"]== "Patient" || $_POST["user"]== "Patient")
{
mysqli_query($con,"UPDATE patient SET password=$_POST[nwpswrd] WHERE email_id =$_POST[loginid] and password=$_POST[oldpswrd]");
if(mysqli_affected_rows($con) ==1)
{
$msgpass="<b><font color=#009900>Password Changed successfully</font></b>";
}
else
{
$msgpass ="<b><font color=#FF0000>Failed to update password</font></b>";
}
}
else if($_POST["user"]== "Administrator")
{
mysqli_query($con,"UPDATE admin SET password=$_POST[nwpswrd] WHERE login_id =$_POST[loginid] and password=$_POST[oldpswrd]");
if(mysqli_affected_rows($con) ==1)
{
$msgpass="<b><font color=#009900>Password Changed successfully</font></b>";
}
else
{
$msgpass ="<b><font color=#FF0000>Failed to update password</font></b>";
}
}
else
{
mysqli_query($con,"UPDATE doctor SET password=$_POST[password] WHERE login_id =$_POST[loginid] and password=$_POST[oldpswrd]");
if(mysqli_affected_rows($con) ==1)
{
$msgpass="<b><font color=#009900>Password Changed successfully</font></b>";
}
else
{
$msgpass ="<b><font color=#FF0000>Failed to update password</font></b>";
}
}
}
?>
<div id="templatemo_main">
<div id="sidebar" class="float_l">
<div class="sidebar_box"><span class="bottom"></span>
<?php
include("sidebar.php");
if($_SESSION["logtype"]==Administrator)
{
adminhome();
}
else if($_SESSION["logtype"]==Patient)
{
patienthome();
}
else if($_SESSION["logtype"]==Doctor)
{
doctorhome();
}
?>
</div>
</div>
<div id="content" class="float_r">
<h2>Change Account Password </h2>
<script type="application/javascript" >
function validation()
{
if(document.form1.user.value == "")
{
alert("Select User Type");
document.form1.user.focus();
return false;
}
if(document.form1.loginid.value=="")
{
alert("Enter Email/Login ID");
document.form1.loginid.focus();
return false;
}
if(document.form1.oldpswrd.value=="")
{
alert("Enter Old Password");
document.form1.oldpswrd.focus();
return false;
}
if(document.form1.nwpswrd.value=="")
{
alert("Enter New Password");
document.form1.nwpswrd.focus();
return false;
}
if(document.form1.nwpswrd.value.length<8 || document.form1.nwpswrd.value.length>15 )
{
alert("minimum charaters for password is 8 and maximum character is 15");
document.form1.nwpswrd.focus();
return false;
}
if(document.form1.cpswrd.value=="")
{
alert("Confirm the new Password");
document.form1.cpswrd.focus();
return false;
}
if(document.form1.nwpswrd.value != document.form1.cpswrd.value)
{
alert("Password not matching...");
return false;
}
}
</script>
<form id="form1" name="form1" method="post" action="" onSubmit="return validation()">
<table width="458" height="241" border="0">
<tr>
<td colspan="2"> <?php echo $msgpass; ?></td>
</tr>
<?php
if($_SESSION["logtype"]==Administrator)
{
?>
<tr>
<td width="99">User Type</td>
<td width="349"><label for="user"></label>
<select name="user" id="user">
<option value="">Select</option>
<option value="Patient">Patient</option>
<option value="Doctor">Doctor</option>
<option value="Administrator">Administrator</option>
</select></td>
</tr>
<?php
}
else
{
echo "<input type=hidden name=user is=user value=Patient>";
}
?>
<tr>
<td><label class="left" for="loginid2" >Login/Email Id</label></td>
<td>
<?php
if($_SESSION["logtype"]==Administrator)
{
?>
<input class="right" name="loginid" type="text" id="loginid" size="50" value="<?php echo $_SESSION[login_id]; ?>" />
<?php
}
elseif($_SESSION["logtype"]==Doctor)
{
?>
<input class="right" name="loginid" type="text" id="loginid" size="50" value="<?php echo $_SESSION[login_id]; ?>" readonly="readonly" />
<?php
}
else
{
?><input class="right" name="loginid" type="text" id="loginid" size="50" readonly="readonly" value="<?php echo $_SESSION[email_id]; ?>" />
<?php
}
?>
</td>
</tr>
<tr>
<td height="40"><label for="oldpswrd" class="left">Old Password</label></td>
<td><input name="oldpswrd" class="right" type="password" id="oldpswrd" size="50" /></td>
</tr>
<tr>
<td>New Password</td>
<td><input name="nwpswrd" class="right" type="password" id="nwpswrd" size="50" /></td>
</tr>
<tr>
<td height="40"><label for="cpswrd" class="left">Confirm Password</label></td>
<td><input name="cpswrd" class="right" type="password" id="cpswrd" size="50" /></td>
</tr>
<tr>
<td height="27" colspan="2" align="center" valign="top"><input type="submit" name="submit" id="submit" value="Change password" class="buttonabc"/></td>
</tr>
</table>
<p> </p>
<p><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<center>
</center>
</p>
</form>
<h1> </h1>
<div id="content_main">
<p>
<center>
</center>
</p>
</div>
</div>
<div class="cleaner"></div>
</div>
<?php
include("includes/footer.php");
?>