The following files exists in this folder. Click to view.
update_user.php16 lines UTF-8 Unix (LF)
<?php
require_once("check_login.php");
require_once("database_connection.php");
# Läs in från formuläret
$username = htmlentities(trim($_POST["username"]));
$password = sha1(trim($_POST["password"]));
$userId = trim($_POST["userId"]); # Trim behövs egentligen inte
# Gör anropet till databasen
$sql = "UPDATE user SET username = :username, password = :password WHERE userId = :userId";
$stm = $pdo->prepare($sql);
$stm->execute(array('username' => $username, 'password' => $password, 'userId' => $userId));
# Skicka till admin med ett meddelande
header("location: admin.php?mess=Användare med ID: $userId har uppdaterats.");