Current directory: /home/klas4s23/domains/585455.klas4s23.mid-ica.nl/public_html/Gastenboek/uploads
<?php
session_start();
if (!isset($_SESSION['username'])) {
header('Location: login.php');
exit();
}
if (isset($_GET['id'])) {
$userId = $_GET['id'];
include_once 'classes/database.php';
$user = database::getUserById($userId);
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$postcode = htmlspecialchars($_POST['postcode']);
$huisnummer = htmlspecialchars($_POST['huisnummer']);
$woonplaats = htmlspecialchars($_POST['woonplaats']);
if (database::updateUser($userId, $postcode, $huisnummer, $woonplaats)) {
header('Location: index.php');
exit();
} else {
$errormsg = "<div style='color: red;'>" . htmlspecialchars(database::$error) . "</div>";
}
}
} else {
header('Location: index.php');
exit();
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Gebruiker Bewerken</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="container">
<h2>Gebruiker Bewerken</h2>
<?php echo isset($errormsg) ? $errormsg : ''; ?>
<form method="post" action="">
<label for="postcode">Postcode:</label>
<input type="text" id="postcode" name="postcode" value="<?php echo htmlspecialchars($user['postcode']); ?>" required>
<label for="huisnummer">Huisnummer:</label>
<input type="text" id="huisnummer" name="huisnummer" value="<?php echo htmlspecialchars($user['huisnummer']); ?>" required>
<label for="woonplaats">Woonplaats:</label>
<input type="text" id="woonplaats" name="woonplaats" value="<?php echo htmlspecialchars($user['woonplaats']); ?>" required>
<input type="submit" value="Wijzig">
</form>
</div>
</body>
</html>