-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathpass-cng-form.php
72 lines (63 loc) · 2.43 KB
/
pass-cng-form.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
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/pass-cng-form.css">
</head>
<body>
<div>
<form action="#" method="post" ><br>
<font color="#B739FE"><h1>Admin Change Password</h1></font>
<br><br>
<div class="crnt-pass">
<img style="margin-bottom: -20px;" src="https://img.icons8.com/nolan/64/privacy.png"/>
<input class="input-box" type="password" name="current-pass" placeholder="CURRENT PASSWORD">
</div>
<br><br>
<div class="new-pass">
<img style="margin-bottom: -20px;" src="https://img.icons8.com/nolan/64/forgot-password.png"/>
<input class="input-box" type="password" name="new-pass" placeholder="NEW PASSWORD">
</div>
<br><br>
<div class="cnfrm-pass">
<img style="margin-bottom: -20px;" src="https://img.icons8.com/nolan/64/forgot-password.png"/>
<input class="input-box" type="password" name="cnfrm-pass" placeholder="CONFIRM PASSWORD">
</div><br>
<button class="button" type="submit" name="Submit" style="vertical-align:middle">
<span>Submit </span>
</button>
</form>
</div>
</body>
</html>
<?php
if (isset($_POST['Submit'])) {
// echo"hello hello mic testing 123 chk chk";
$con=mysqli_connect('localhost','root','','rms');
if (!$con) {
die("Connection failed");
}
else{
$currentpass = $_POST['current-pass'];
$newpass = $_POST['new-pass'];
$cnfrmpass = $_POST['cnfrm-pass'];
$sql = "SELECT password FROM admin ";
$result = mysqli_query($con,$sql);
$row = mysqli_fetch_array($result);
$oldpass = $row["password"];
if($currentpass != $oldpass ){
echo '<script> alert("current password wrong");</script>';
}
else if($newpass !== $cnfrmpass){
echo '<script> alert("pasword not matched");</script>';
}
else{
$sql ="UPDATE `admin` SET `password`='$newpass' WHERE `id`='1'";
$res = mysqli_query($con,$sql);
if($res)
echo '<script> alert("password changed sucessfully!!");</script>';
else
echo '<script> alert("opss!!");</script>';
}
}
}
?>