-
Notifications
You must be signed in to change notification settings - Fork 0
/
change_password.php
67 lines (63 loc) · 2.81 KB
/
change_password.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
<?php
require_once("connection.php");
if(!isset($_SESSION)){
session_start();
}
if(isset($_POST["old"])){
$old = getValue($_POST["old"]);
$new = getValue($_POST["new"]);
$sql = "SELECT * FROM users WHERE employee_id=". $_SESSION["login"] . " AND user_password= PASSWORD('". $old ."')";
$result = mysqli_query($con, $sql);
if(mysqli_num_rows($result) == 1){
$sql = "UPDATE users SET user_password= PASSWORD('$new') WHERE employee_id=". $_SESSION["login"];
if(mysqli_query($con, $sql)){
header("location:change_password.php?change=done");
} else {
header("location:change_password.php?error=notchange");
}
}else{
header("location:change_password.php?old=wrong");
}
}
?>
<?php require_once("top.php"); ?>
<div class="card card-body col-lg-6 offset-lg-3 mt-5 " >
<div class="card card-header text-info">
<h1 >Change Password</h1>
</div>
<!-- Alert section -->
<!-- change password successful -->
<?php if(isset($_GET["change"])){ ?>
<div class="alert alert-success alert-dismissable col-lg-8 col-lg-offset-2" style="font-size:23px; margin-top: 20px; color:tomato; text-align:center">
<button class="close " area-hidden="true" data-dismiss="alert" style="font-size:30px; color:red">X</button>
Successful ! په بریالئ توگه ستاسو کود تغیر شو! مننه
</div>
<?php } ?>
<!-- Old password Wrong -->
<?php if(isset($_GET["old"])){ ?>
<div class="alert alert-danger alert-dismissable col-lg-8 col-lg-offset-2" style="font-size:23px; margin-top: 20px; color:tomato; text-align:center">
<button class="close " area-hidden="true" data-dismiss="alert" style="font-size:30px; color:red">X</button>
Wrong ! ستاسو پخوانئ کود غلت دی
</div>
<?php } ?>
<!-- end-->
<div class="card card-body">
<form method="post" id="change" >
<div class="input-group-text m-2">
<span class="w-25 h6 mr-5">Old Password:</span>
<input autofocus="autofocus" type="password" class="form-control " name="old">
</div>
<div class="input-group-text m-2">
<span class="w-25 h6 mr-5">New Password:</span>
<input minlength="6" id="new" type="password" class="form-control" name="new">
</div>
<div class="input-group-text m-2">
<span class="w-25 h6 mr-4">Retype Password:</span>
<input minlength="6" id="retype" type="password" class="form-control" name="retype">
</div>
<input type="submit" value="Change Password" class="btn btn-success m-2">
</form>
</div>
</div>
<!-- code by faizullah firozi wardak 0780002528 -->
<?php require_once("footer.php"); ?>