26 lines
637 B
PHP
26 lines
637 B
PHP
|
<?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())
|
||
|
{
|
||
|
echo json_encode(array("message" => "ok"));
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
echo json_encode(array("message" => "Error updating password"));
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
echo json_encode(array("message" => "Not logged in"));
|
||
|
}
|