-
Notifications
You must be signed in to change notification settings - Fork 0
/
resetadmin.php
126 lines (119 loc) · 4.45 KB
/
resetadmin.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>COMPLAINT MANAGEMENT PORTAL</title>
<link href="styling.css" rel="stylesheet">
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href='https://fonts.googleapis.com/css?family=Arvo' rel='stylesheet' type='text/css'>
<script src="js/jquery-3.3.1.min.js"></script>
<style>
#q1{
color:red;
transform:translate(550px,17px);
}
#q2{
color:red;
transform:translate(550px,17.5px);
}
#q3{
color:red;
transform:translate(550px,18px);
}
#q4{
color:red;
transform:translate(550px,18.5px);
}
#q5{
color:#17e9ae;
transform:translate(550px,17px);
}
</style>
</head>
<body>
<div class="contain">
<div id="head">
<h5 id="add"><span class="add1">COMPLAINT ADDRESSAL PORTAL -> </span>HOME | ADMIN | RESET PASSWORD<span class="back"><a href="admin1.php" class="link"><u>BACK</u></a></span></h5>
<br /><br />
<h2 id="add4"><u>Enter your password details :</u></h2>
</div>
</div>
<?php
$var=$_COOKIE["adminpass"];
$link=@mysqli_connect("localhost","root","","cms") or die("Error:Unable to connect: " . mysqli_connect_error());
$name = isset($_POST["name"])?$_POST["name"]:" ";
$password = isset($_POST["pass"])?$_POST["pass"]:" ";
$repassword = isset($_POST["pass1"])?$_POST["pass1"]:" ";
$x=0;
//if the user has submitted the form
if(isset($_POST["submit"])){
//check for errors
if(!$name){
echo "<p id=q1>Please enter your current password!</p>";
$x=1;
}else{
$name = filter_var($name,FILTER_SANITIZE_STRING);
}
if($var!=$name)
{
echo "<p id=q1>Invalid current password!</p>";
$x=1;
}
if(!$password){
echo "<p id=q2>Please enter your new password!</p>";
$x=1;
}
else{
if(!preg_match("/^[a-zA-Z]\w{7,19}$/",$password)){
echo "<p id=q3>Invalid format!</p>";
$x=1;
}
}
if(!$repassword){
echo "<p id=q4>Please confirm your password!</p>";
$x=1;
}
else if($repassword!=$password){
echo "<p id=q4>The password does not match!</p>";
$x=1;
}
if($x==0)
{
$name=mysqli_real_escape_string($link,$name);
$password=mysqli_real_escape_string($link,$password);
$sql="UPDATE admin SET password='$password' where password='$name'";
if($result=mysqli_query($link,$sql)){
echo "<p id=q5>Your password has been reset</p>";
}
}
}
mysqli_close($link);
?>
<div class="adds" id="adds1">
<form action="resetadmin.php" method="post">
<br />
<div class="form-group">
<input type="password" class="ut" id="currentpassadmin" name="name" placeholder="Enter current password" size="30px" maxlength="100" class="form-control" value="<?php if(isset($_POST["name"])) echo $_POST["name"];?>"></div>
<br />
<div class="form-group">
<input type="password" class="ut" name="pass" id="newpassadmin" placeholder="Enter new password" size="30px" maxlength="100" class="form-control" value="<?php if(isset($_POST["pass"])) echo $_POST["pass"];?>"> </div>
<img src="imgs/ques1.png" class="bodyimagey">
<div class="msg2"></div>
<div class="form-group">
<input type="password" class="ut" name="pass1" id="confirmpassadmin" placeholder="Re-enter new password" size="30px" maxlength="100" class="form-control" value="<?php if(isset($_POST["pass1"])) echo $_POST["pass1"];?>"></div> <br />
<input type="submit" name="submit" class="btn btn-success btn-lg" id="button1" value="RESET" style="background-color:#17e9ae;">
</form>
</div>
<script>
$(function(){
$(".bodyimagey").mouseover(function(){
$(".msg2").html("Password should be minimum 8 characters long and the first character must be a letter and no characters other than letters and number should be used.");
});
$(".bodyimagey").mouseout(function(){
$(".msg2").html("<p></p>");
});
});
</script>
</body>
</html>