View sourcecode

The following files exists in this folder. Click to view.

update_user.php

16 lines UTF-8 Unix (LF)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?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.");