Password changed
Your password has been changed.
prepare("SELECT user, (NOW() > request_date + INTERVAL 1 DAY) AS expired FROM requests_password WHERE id = ?");
if (!$statement) {
$errorMessage = "An unexpected error occurred while changing the password.";
} else {
$statement->bind_param('i', $_POST['id']);
$statement->execute();
$result = $statement->get_result();
if (!$result) {
$errorMessage = "An unexpected error occurred while changing the password.";
$statement->close();
} else {
$request = $result->fetch_assoc();
$statement->close();
if (!$request) {
$errorMessage = "Invalid request ID.";
} else {
$expired = false;
if ($request['expired']) {
$expired = true;
$errorMessage = "Invalid request ID.";
}
if (!$expired) {
$statement = $connection->prepare("SELECT id, username, email, is_suspended, is_verified FROM users WHERE id = ? AND is_deleted = 0");
if (!$statement) {
$errorMessage = "An unexpected error occurred while changing the password.";
} else {
$statement->bind_param('i', $request['user']);
$statement->execute();
$result = $statement->get_result();
if (!$result) {
$errorMessage = "An unexpected error occurred while changing the password.";
$statement->close();
} else {
$userData = $result->fetch_assoc();
$statement->close();
if (!$userData) {
$errorMessage = "Your account doesn't exist.";
} elseif ($userData['is_suspended']) {
$errorMessage = "Your account is suspended.";
} elseif (!$userData['is_verified']) {
$errorMessage = "Your account is not activated yet.";
} else {
$statement = $connection->prepare("UPDATE users SET password = ? WHERE id = ?");
if (!$statement) {
$errorMessage = "An unexpected error occurred while changing the password.";
} else {
$hashedPassword = password_hash($_POST['password'], PASSWORD_DEFAULT);
$statement->bind_param('si', $hashedPassword, $request['user']);
if (!$statement->execute()) {
$errorMessage = "An unexpected error occurred while changing the password.";
} else {
$passwordChanged = true;
session_regenerate_id(true);
$_SESSION['user'] = $request['user'];
}
$statement->close();
}
}
}
}
}
}
$statement = $connection->prepare("DELETE FROM requests_password WHERE id = ?");
if (!$statement) {
$errorMessage = "An unexpected error occurred while changing the password.";
} else {
$statement->bind_param('s', $_POST['id']);
if (!$statement->execute()) {
$errorMessage = "An unexpected error occurred while changing the password.";
}
$statement->close();
}
}
}
}
}
if ($passwordChanged) {
$pageTitle = "Password changed";
$pageDescription = "Your password has been changed.";
} else {
$pageTitle = "Change password";
$pageDescription = "Change your password in SVR.JS Mods directory.";
}
include 'header.php';
?>
Your password has been changed.Password changed
Change password