View sourcecode

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

updateUser.php

23 lines UTF-8 Unix (LF)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
require_once('check_login.php');
require_once(
'database_connection.php');

# Läs in från formuläret
$username trim($_POST['username']);
$password 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"
;
$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.");