The following files exists in this folder. Click to view.
edit_user.php50 lines UTF-8 Unix (LF)
<?php
require_once("check_login.php");
require_once("database_connection.php");
$userId = trim($_GET['userId']); # Hämta vilket id som ska uppdateras
# Bygg upp SQL-sats och gör anropet till databasen
$sql = "SELECT * FROM user WHERE userId = :userId;";
$stm = $pdo->prepare($sql);
$stm->execute(array('userId' => $userId));
# fetch() eftersom vi hämtar en post
$res = $stm->fetch(PDO::FETCH_ASSOC);
?>
<!DOCTYPE html>
<html lang="sv">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie-edge">
<title>Lägg till användare</title>
<link rel="stylesheet"
href ="https://unpkg.com/spectre.css/dist/spectre.min.css">
</head>
<body>
<div class="container">
<div class="columns">
<div class="column col-4">
<h1>Inloggnignsapplikationen</h1>
<p>Uppdatera information om användare</p>
<form method="POST" action="update_user.php">
<div class="form-group">
<input type="hidden" name="userId" value="<?php echo $userId;?>">
<label class="form-label" for="username">Användarnamn</label>
<input class="form-input" id="username" name="username" type="text"
value="<?php echo $res['username'];?>" required>
<label class="form-label" for="password">Lösenord</label>
<input class="form-input" id="password" name="password" type="password"
value="<?php echo $res['password'];?>" required>
<p></p>
<input type="submit" class="btn btn-primary" value="Uppdatera">
</div>
</form>
</div>
</div>
</div>
</body>
</html>