The following files exists in this folder. Click to view.
editUser.php69 lines UTF-8 Unix (LF) 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
<?php
require_once('check_login.php'); # Kollar om vi är inloggade
require_once('database_connection.php'); # Läs in databaskopplingen
$userId = trim($_GET['userId']); # hämta vilket id som skall 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));
# 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=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Uppdatera användare</title>
<!-- Bulma -->
<link rel="stylesheet" href="bulma.css">
</head>
<body>
<section class="section">
<div class="container">
<div class="columns is-centered">
<div class="column is-4">
<h1 class="title">Inloggningsapplikationen</h1>
<p class="subtitle">Uppdatera information om användare</p>
<form method="POST" action="updateUser.php">
<input type="hidden" name="userId" value="<?php echo $userId; ?>">
<div class="field">
<label class="label" for="username">Användarnamn</label>
<div class="control">
<input class="input" id="username" name="username"
type="text" value="<?php echo $res['username']; ?>" required>
</div>
</div>
<div class="field">
<label class="label" for="password">Lösenord</label>
<div class="control">
<input class="input" id="password" name="password"
type="password" value="<?php echo $res['password']; ?>" required>
</div>
</div>
<div class="field">
<button class="button is-primary is-fullwidth">
Uppdatera
</button>
</div>
</form>
</div>
</div>
</div>
</section>
</body>
</html>