-
Notifications
You must be signed in to change notification settings - Fork 2
/
updatepasswordreset.php
35 lines (24 loc) · 888 Bytes
/
updatepasswordreset.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
<?php
//To Handle Session Variables on This Page
//Including Database Connection From db.php file to avoid rewriting in all files
require_once("db.php");
//if user Actually clicked update profile button
if(isset($_POST)) {
$password = mysqli_real_escape_string($conn, $_POST['password']);
$email = mysqli_real_escape_string($conn, $_POST['email']);
$sql = "UPDATE users SET password = '$password'";
$sql .= " WHERE email='$email'";
if($conn->query($sql) === TRUE) {
//If data Updated successfully then redirect to dashboard
header("Location: login.php");
exit();
} else {
echo "Error ". $sql . "<br>" . $conn->error;
}
//Close database connection. Not compulsory but good practice.
$conn->close();
} else {
//redirect them back to dashboard page if they didn't click update button
header("Location: index.php");
exit();
}