forked from ss250294/NGO-portal-website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
donorchangepassword.php
54 lines (46 loc) · 1.45 KB
/
donorchangepassword.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
<?php
include 'connect.php';
require_once('auth.php');
//fetches current password, new password and confirmed password
$cur_pass = sha1($_POST['currentPassword']);
$new_pass = sha1($_POST['newPassword']);
$confirm_pass = sha1($_POST['confirmPassword']);
//fetches id and email of donor
if(isset($_SESSION['SESS_MEMBER_ID'])){
$pid=$_SESSION['SESS_MEMBER_ID'];
$current_email=$_SESSION['SESS_EMAIL'];
}
$qry="SELECT * FROM Donor WHERE pid=$pid AND password='$cur_pass'";
$result=mysql_query($qry);
if($result)
{
if(mysql_num_rows($result) > 0)
{
if($new_pass == $confirm_pass) //checks if new password is same as confirm password
{
//updates password
$updateQuery = "UPDATE Donor SET password='".$new_pass."' WHERE email='".$current_email."'";
$result = mysql_query($updateQuery);
if($result)
{
Header("refresh:0.001;url=".$_SESSION['LINK_DONORHOME']."?id=".$pid);
return true;
}
}
else //if new password & confirm password don't match then display password mismatch
{
echo "Password Mismatch";
Header("refresh:0.001;url=".$_SESSION['LINK_DONORHOME']."?id=".$pid);
}
}
else //if current password entered isn't the correct one then display incorrect password
{
?>
<script>
alert("Incorrect password");
</script>
<?php
Header("refresh:0.001;url=".$_SESSION['LINK_DONORHOME']."?id=".$pid);
}
}
?>