The following files exists in this folder. Click to view.
updateUser.php21 lines UTF-8 Unix (LF)
<?php
require_once "check_login.php";
require_once "database_connection.php";
$userId = (int)($_POST["userId"] ?? 0);
$username = trim($_POST["username"] ?? "");
$password = trim($_POST["password"] ?? "");
if ($userId < 1 || $username === "" || $password === "") {
header("Location: admin.php?mess=Felaktiga värden.");
exit;
}
$sql = "UPDATE user SET username=?, password=? WHERE userId=?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("ssi", $username, $password, $userId);
$stmt->execute();
header("Location: admin.php?mess=Användare uppdaterad.");
exit;