-
Notifications
You must be signed in to change notification settings - Fork 0
/
AdminChangePasswordmy.php
42 lines (34 loc) · 1.29 KB
/
AdminChangePasswordmy.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
<?php
include('UserSessionAdmin.php');
if(isset($_POST["submit"])=="Change Password")
{
$CurrentPassword = $_POST[CurrentPassword]; //CurrentPassword
$ConfirmPassword = $_POST[ConfirmPassword]; //ConfirmPassword
// We Will prepare SQL Query
$STM = $dbh->prepare("SELECT Password FROM members WHERE UserName = :user");
// bind paramenters, Named paramenters alaways start with colon(:)
$STM->bindParam(':user', $_SESSION[myusername]);
// For Executing prepared statement we will use below function
$STM->execute();
// Count no. of records
$count = $STM->rowCount();
//just fetch. only gets one row. So no foreach loop needed :D
$row = $STM -> fetch();
$cuurentpassworddb=$row[0];
if($cuurentpassworddb==$CurrentPassword)
{
// We Will prepare SQL Query
$STM2 = $dbh->prepare("UPDATE members SET Password=:ConfirmPassword WHERE UserName=:user");
// bind paramenters, Named paramenters alaways start with colon(:)
$STM2->bindParam(':user', $_SESSION[myusername]);
$STM2->bindParam(':ConfirmPassword', $ConfirmPassword);
// For Executing prepared statement we will use below function
$STM2->execute();
header( "location:AdminIndex.php?AdminChangePassword=77083368");
}
else
{
header( "location:AdminIndex.php?AdminChangePassword=37767");
}
}
?>