The following files exists in this folder. Click to view.
updateUser.php23 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 user1
SET username = :username, password = :password
WHERE userId = :userId";
$stmt = $pdo->prepare($sql);
$stmt->execute(array(
'username' => $username,
'password' => $password,
'userId' => $userId
));
# skicka till admin med ett meddelande
header("location: admin.php?mess=Användaren med id: $userId har uppdaterats.");