-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate.php
More file actions
47 lines (40 loc) · 1.48 KB
/
Copy pathupdate.php
File metadata and controls
47 lines (40 loc) · 1.48 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
<?php
ob_start();
session_start();
DEFINE ('DB_USER', 'root');
DEFINE ('DB_PASSWORD', '');
DEFINE ('DB_HOST', 'localhost');
DEFINE ('DB_NAME', 'cookbook');
$connection = mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
if (isset($_POST['username']))
{
$usernameInput = $_POST['username'];
$query = "SELECT user_name FROM users WHERE user_name = '$usernameInput'";
$result = $connection->query($query);
$row = mysqli_fetch_array($result);
if ($row && $row['user_name'] === $usernameInput)
{
?>
<html>
<body>
<h2>Reset Password</h2>
<form action="save_password.php" method="post">
<input type="hidden" name="username" value="<?php echo $usernameInput; ?>">
<p>New Password:</p>
<input type="password" name="new_password" required>
<p>Confirm Password:</p>
<input type="password" name="confirm_password" required>
<br><br>
<button type="submit">Update Password</button>
</form>
</body>
</html>
<?php
}
else
{
echo "<h3>Error: Username not found or case does not match exactly.</h3>";
echo "<br><a href='forget_password.html'>Try Again</a>";
}
}
?>