-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetting-pass.php
49 lines (38 loc) · 1017 Bytes
/
setting-pass.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
<?php
session_start();
if( isset($_SESSION['admin']) ) {
$admin = $_SESSION['admin'];
}
include 'database/connect.php';
include 'functions.php';
include 'langCheck.php';
protectAdmin();
$oldPass = $_POST['oldpass'];
$newPass = $_POST['newpass'];
$repPass = $_POST['reppass'];
if( empty($oldPass) || empty($newPass) || empty($repPass) ) {
echo $lang['fillAllFields'];
exit();
}
$oldPass = encrypt($oldPass);
$query = $con->prepare("SELECT * FROM admin WHERE username = ? AND password = ?");
$query->bind_param("ss", $admin, $oldPass);
$query->execute();
$query->store_result();
$nm = $query->num_rows;
$query->close();
if($nm == 0){
echo $lang['passwordInvalid'];
exit();
}
if($newPass !== $repPass){
echo $lang['passwordsNotMatch'];
exit();
}
$newPass = encrypt($newPass);
$query = $con->prepare("UPDATE admin SET password = ? WHERE username = ?");
$query->bind_param("ss", $newPass, $admin);
$query->execute();
$query->close();
echo $lang['passwordChanged'];
?>