-
Notifications
You must be signed in to change notification settings - Fork 1
/
update_profile.php
48 lines (40 loc) · 1.43 KB
/
update_profile.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
require_once 'includes/auth.php';
requireLogin();
$user = getUserById($_SESSION['user_id']);
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$username = $_POST['username'];
$password = $_POST['password'];
$email = $_POST['email'];
updateUser($_SESSION['user_id'], $username, $password, $email);
$user = getUserById($_SESSION['user_id']);
$successMessage = "Profile updated successfully.";
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Update Profile</title>
</head>
<body>
<?php include 'includes/header.php'; ?>
<h1>Update Profile</h1>
<?php if (isset($successMessage)): ?>
<p><?php echo htmlspecialchars($successMessage); ?></p>
<?php endif; ?>
<form action="update_profile.php" method="post">
<label for="username">Username:</label>
<input type="text" id="username" name="username" value="<?php echo htmlspecialchars($user['username']); ?>" required>
<br>
<label for="password">Password:</label>
<input type="password" id="password" name="password" value="<?php echo htmlspecialchars($user['password']); ?>" required>
<br>
<label for="email">Email:</label>
<input type="email" id="email" name="email" value="<?php echo htmlspecialchars($user['email']); ?>" required>
<br>
<input type="submit" value="Update">
</form>
<?php include 'includes/footer.php'; ?>
</body>
</html>