-
Notifications
You must be signed in to change notification settings - Fork 1
/
reset.php
59 lines (42 loc) · 1.39 KB
/
reset.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
<?php include 'controllers/authController.php' ?>
<?php
// FORGOT USER
if (isset($_POST['reset-btn'])) {
if (empty($_POST['password']))
{
$errors['password'] = 'Password required';
}
echo'before email';
$email = $_REQUEST['Email'];
if (isset($_GET['Email'])) {
# code...
$toke = $_GET['Email'];
echo $toke;
}
$password = password_hash($_POST['password'], PASSWORD_DEFAULT); //encrypt password
// Check if email already exists
$sql = "UPDATE users SET password='{$password}'where token ='{$toke}";
$result = mysqli_query($conn, $sql);
if ($result) {
echo'inse success';
header('location: ./login.php');
}
// if (count($errors) === 0)
// {
// $password = password_hash($_POST['password'], PASSWORD_DEFAULT); //encrypt password
// // "UPDATE users SET password=? where email = '$email'";
// $query = "UPDATE users SET password=? where email = ?";
// $stmt = $conn->prepare($query);
// $stmt->bind_param('ss', $password, $email);
// $result = $stmt->execute();
// if ($result) {
// $stmt->close();
// header('location: ./login.php');
// }
else
{
$_SESSION['error_msg'] = "Database error: Could not register user";
}
// }
}
?>