-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathupdate-password.php
More file actions
60 lines (45 loc) · 1.42 KB
/
update-password.php
File metadata and controls
60 lines (45 loc) · 1.42 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
<?php
include("includes/db_conn.php");
$ErrorReset = array();
if(isset($_POST['reset']))
{
$fullname = mysqli_real_escape_string($db, $_POST['fullname']);
$new_pass = mysqli_real_escape_string($db, $_POST['new_pass']);
$con_pass = mysqli_real_escape_string($db, $_POST['con_pass']);
if(empty($fullname) || empty($new_pass) || empty($con_pass))
{
if($fullname == "")
{
$ErrorReset[] = "Your full name is required";
}
if($new_pass == "")
{
$ErrorReset[] = "New password field is required";
}
if($con_pass == "")
{
$ErrorReset[] = "Confirm password field is required";
}
if($con_pass != $new_pass)
{
$ErrorReset[] = "Passwords do not match";
}
}
else
{
$query = "SELECT * FROM admin_tbl WHERE fullname = '$fullname'";
$Result = mysqli_query($db, $query);
if(mysqli_num_rows($Result))
{
$update = "UPDATE admin_tbl SET admin_password = '$new_pass' WHERE fullname = '$fullname'";
$run_up = mysqli_query($db, $update);
echo "<script>alert('Password reset done successfully!')</script>";
echo "<script>document.location='login.php'</script>";
}
else
{
$ErrorReset[] = "Your name does not exists";
}
}
}
?>