forked from Kr321Manish/azure_project
-
Notifications
You must be signed in to change notification settings - Fork 1
/
admin-resetp.php
129 lines (112 loc) · 3.68 KB
/
admin-resetp.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?php
$error = "";
$service_no="";
$new_paswword="";
$confirm_paswword="";
session_start();
// echo $_SESSION['service_no'];
if(isset($_SESSION['service_no'])){
$serverName = ""; // update me
$connectionOptions = array(
"Database" => "maindatabase", // update me
"Uid" => "", // update me
"PWD" => "" // update me
);
//Establishes the connection
$conn = sqlsrv_connect($serverName, $connectionOptions);
if($conn==false){
die(print_r(sqlsrv_errors(), true));
}else{
// echo "Connection Success"."<br>";
if (array_key_exists("update_password", $_POST)){
$service_no=$_REQUEST['service_no'];
$new_paswword=$_REQUEST['new_password'];
$confirm_paswword=$_REQUEST['confirm_password'];
// print_r("$service_no"."=>"."$new_paswword"."=>"."$confirm_paswword");
if ($service_no==$_SESSION['service_no']) {
if($new_paswword!=$confirm_paswword){
$error="Password did not match";
}else{
// echo "Ready to update";
$sql="UPDATE admin SET password='$new_paswword' WHERE service_no='$service_no'";
$results=sqlsrv_query($conn,$sql);
if ($results) {
echo '<script>alert("Password Changed Succesfully");
window.location.href = "admin.php";</script>';
session_unset();
session_destroy();
exit();
}else{
$error="Facing Some error please try Again later";
}
}
}else{
$error="Incorrect Sevice No";
}
}
}
}else{
header("Location: index.php");
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Admin-login</title>
<link rel="stylesheet" href="Admin-style.css?v=<?php echo time(); ?>">
<!-- <link rel="stylesheet" type="text/css" href="Admin-style.css"> -->
<!-- for font -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Thai+Looped:wght@500&display=swap" rel="stylesheet">
<!-- -->
</head>
<body>
<div class="container">
<h1>Welcome to Admin Page</h1>
<form id="form-2" method="post">
<div class="error">
<?php echo "$error";?>
</div>
<div class="combo">
<fieldset>
<legend>Service no*</legend>
<input type="text" name="service_no" placeholder="*service-no" required value="<?php echo $service_no ?>">
</fieldset>
</div>
<div class="combo">
<fieldset>
<legend>New Password*</legend>
<input type="Password" name="new_password" placeholder="*password" required value="<?php echo $new_paswword ?>" id="pass">
<img src="1.svg" class="eye" onclick="myFunction('pass')">
</fieldset>
</div>
<div class="combo">
<fieldset>
<legend>Confirm Password*</legend>
<input type="Password" name="confirm_password" placeholder="*confirm-password" required value="<?php echo $confirm_paswword ?>" id="cpass">
<img src="1.svg" class="eye" onclick="myFunction('cpass')">
</fieldset>
</div>
<div class="combo-1">
<button name="update_password">Update</button>
</div>
</form>
<a href="index.php">Back to home</a>
</div>
<!-- ==================javascript============= -->
<script type="text/javascript">
function myFunction(clicked_id) {
// alert(clicked_id);
var x = document.getElementById(clicked_id);
if (x.type === "password") {
x.type = "text";
} else {
x.type = "password";
}
}
</script>
</body>
</html>