-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchange.php
More file actions
32 lines (24 loc) · 713 Bytes
/
Copy pathchange.php
File metadata and controls
32 lines (24 loc) · 713 Bytes
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
<?php
if($_SERVER["REQUEST_METHOD"] == "POST") {
$username = $_POST['username'];
$oldpassword = $_POST['oldpassword'];
$newpassword = $_POST['newpassword'];
$conn = new mysqli("localhost", "root", "", "auth");
if($conn->connect_error){
die("Connection failed: ". $conn->connect_error);
}
$sql = "UPDATE login SET password='$newpassword' WHERE username='$username' AND password='$oldpassword'";
// Login successful
if($conn->query($sql) === TRUE){
echo "Successfully changed the password";
header("Location: index.html");
exit();
}
// Login failed
else{
echo "ERROR";
exit();
}
$conn->close();
}
?>