-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdatepassword.php
136 lines (125 loc) · 2.96 KB
/
updatepassword.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
130
131
132
133
134
135
136
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Atualização de senha</title>
</head>
<style rel="stylesheet" type="text/css">
* {
margin: 0;
padding: 0;
box-sizing: border-box;
text-decoration: none;
font-family: sans-serif;
}
form {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
background-color: #dbdbdb;
box-shadow: 2px 5px 30px 5px #000000;
width: 350px;
color: #fff;
border-radius: 5px;
padding: 20px 25px 30px 25px;
}
form h3 {
margin-bottom: 15px;
color: #000000;
}
form input {
width: 100%;
margin-bottom: 20px;
background-color: transparent;
border: none;
border-bottom: 2px solid #00d9ff;
border-radius: 0;
padding: 5px 0;
font-weight: 550;
font-size: 14px;
outline: none;
}
form button {
font-weight: 550;
font-style: 15px;
color: white;
background-color: #380079;
padding: 4px 10px;
border-radius: 12px;
border: none;
outline: none;
}
</style>
<body>
<?php
require("connection.php");
if(isset($_GET['email']) && isset($_GET['reset_token']))
{
date_default_timezone_set('Asia/kolkata');
$date=date("Y-m-d");
$query="SELECT * from `registered_users` WHERE `email`='$_GET[email]' AND `resettoken`='$_GET[reset_token]' AND `resettokenexpire`='$date'";
$result=mysqli_query($con,$query);
if($result)
{
if(mysqli_num_rows($result)==1)
{
echo"
<form method='POST'>
<h3>Criar nova senha</h3>
<input type='password' placeholder='Nova Senha' name='Password'>
<button type='submit' name='updatepassword'>ATUALIZAR</button>
<input type='hidden' name='email' value='$_GET[email]'>
</form>
";
}
else
{
echo"
<script>
alert('Link inválido ou expirado');
window.location.href='index.php';
</script>
";
}
}
else
{
echo"
<script>
alert('Servidor caiu! tente mais tarde');
window.location.href='index.php';
</script>
";
}
}
?>
<?php
if(isset($_POST['updatepassword']))
{
$pass=password_hash($_POST['Password'],PASSWORD_BCRYPT); #Senha CRIPTOGRAFADA
$update="UPDATE `registered_users` SET `password`='$pass',`resettoken`=NULL,`resettokenexpire`=NULL WHERE `email`='$_POST[email]'";
if(mysqli_query($con,$update))
{
echo"
<script>
alert('Senha atualizada com sucesso');
window.location.href='index.php';
</script>
";
}
else
{
echo"
<script>
alert('Servidor caiu! tente mais tarde');
window.location.href='index.php';
</script>
";
}
}
?>
</body>
</html>