-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreset_password.php
More file actions
147 lines (131 loc) · 4.36 KB
/
reset_password.php
File metadata and controls
147 lines (131 loc) · 4.36 KB
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<?php require_once 'inc/connection.php';?>
<?php
require 'inc/function.php';
session_start();
if(isset($_POST['submit']))
{
$errors=array();
$newPassword=$_POST['newpassword'];
$confirmPassword=$_POST['confirmpassword'];
if(empty($newPassword || $confirmPassword))
{
$errors[]="Password required!";
}
if($newPassword != $confirmPassword)
{
$errors[]="Please enter the same password!";
}
if((strlen(trim($newPassword))<6))
{
$errors[]="Password must contain at least 6 characters!";
}
if(empty($errors))
{
$hashed_password = sha1($confirmPassword);
$email=$_SESSION['email'];
$level=$_SESSION['level'];
$newtoken= bin2hex(random_bytes(50));
$query="UPDATE ".$level." SET password='{$hashed_password}',token='{$newtoken}' WHERE email='{$email}' Limit 1";
$result_set=mysqli_query($connection,$query);
if($result_set)
{
header('location:login.php');
}
else
{
header('location:reset_password.php');
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Reset password-Ceylon Trek</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="css/reset_password.css">
<link rel="stylesheet" href="css/top_bar.css">
<link rel="stylesheet" href="css/footer.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body style="background-image: url('img/ct2.jpg'); background-size:cover;background-position: center center;background-attachment: fixed; background-repeat:no-repeat;">
<?php include('inc/top_bar.php'); ?>
<div class="reset_password_box">
<h1>Reset Password</h1>
<form action="reset_password.php" method="post">
<?php
if(isset($_POST['submit'])){
if(empty($newPassword) || empty($confirmPassword))
{
echo '<p class="error">Password requried!</p>';
}
if($newPassword != $confirmPassword)
{
echo '<p class="error">Please enter the same password!</p>';
}
if((strlen(trim($newPassword))<6))
{
echo '<p class="error">Password must contain at least 6 characters!</p>';
}
}
?>
<div class="text_box">
<i class="fa fa-lock fa-2x" aria-hidden="true"></i>
<input type="password" name="newpassword" placeholder="New Password" id="myInput1" >
<span class="eye" onclick="myFunction1()">
<i id="hide1" class="fa fa-eye"></i>
<i id="hide2" class="fa fa-eye-slash"></i>
</span>
<script>
function myFunction1(){
var x=document.getElementById("myInput1");
var y=document.getElementById("hide1");
var z=document.getElementById("hide2");
if(x.type === "password"){
x.type ="text";
y.style.display = "block";
z.style.display = "none";
}
else{
x.type ="password";
y.style.display = "none";
z.style.display = "block";
}
}
</script>
</div><!-- text_box -->
<div class="text_box">
<i class="fa fa-lock fa-2x" aria-hidden="true"></i>
<input type="password" name="confirmpassword" placeholder="Confirm Password" id="myInput2">
<span class="eye" onclick="myFunction2()">
<i id="hide-1" class="fa fa-eye"></i>
<i id="hide-2" class="fa fa-eye-slash"></i>
</span>
<script >
function myFunction2(){
var x=document.getElementById("myInput2");
var y=document.getElementById("hide-1");
var z=document.getElementById("hide-2");
if(x.type === "password"){
x.type ="text";
y.style.display = "block";
z.style.display = "none";
}
else{
x.type ="password";
y.style.display = "none";
z.style.display = "block";
}
}
</script>
</div><!-- text_box -->
<a href="Login.php">« Back</a>
<button style="background-color:#2f375b;" type="submit" name="submit">Submit</button>
</form>
</div><!-- reset_password_box -->
<?php include('inc/footer.php'); ?>
</body>
</html>
<?php mysqli_close($connection);?>