2022-12-03 12:57:42 +00:00
|
|
|
<?php
|
|
|
|
session_start();
|
|
|
|
require_once 'config.php';
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
|
|
|
|
if (isset($_SESSION["username"]))
|
|
|
|
{
|
|
|
|
$pass = $_POST["password"];
|
|
|
|
$conn = dbConn();
|
|
|
|
$stmt = $conn->prepare("UPDATE Users SET Users_password = :pass WHERE Users_username = :username");
|
|
|
|
$stmt->bindParam(":pass", $pass);
|
|
|
|
$stmt->bindParam(":username", $_SESSION["username"]);
|
|
|
|
if ($stmt->execute())
|
|
|
|
{
|
2022-12-16 12:19:38 +00:00
|
|
|
|
|
|
|
$logSQL = "INSERT INTO Logs (Logs_type, Users_username, Logs_date) VALUES ('Change password', :username, NOW())";
|
|
|
|
$logStmt = $conn->prepare($logSQL);
|
|
|
|
$logStmt->bindParam(":username", $_SESSION["username"]);
|
2022-12-03 12:57:42 +00:00
|
|
|
echo json_encode(array("message" => "ok"));
|
2022-12-16 12:19:38 +00:00
|
|
|
$logStmt->execute();
|
2022-12-03 12:57:42 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
echo json_encode(array("message" => "Error updating password"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
echo json_encode(array("message" => "Not logged in"));
|
|
|
|
}
|