-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofil.php
More file actions
150 lines (132 loc) · 5.95 KB
/
profil.php
File metadata and controls
150 lines (132 loc) · 5.95 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<?php
session_start();
require 'config.php';
if (!isset($_SESSION['user_id'])) {
header('Location: login.php');
exit;
}
$user_id = $_SESSION['user_id'];
$sql = "SELECT full_name, email, bio FROM users WHERE id = ?";
$stmt = $pdo->prepare($sql);
$stmt->execute([$user_id]);
$user = $stmt->fetch(PDO::FETCH_ASSOC);
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$full_name = $_POST['full_name'];
$email = $_POST['email'];
$bio = $_POST['bio'];
$sql = "UPDATE users SET full_name = ?, email = ?, bio = ? WHERE id = ?";
$stmt = $pdo->prepare($sql);
$result = $stmt->execute([$full_name, $email, $bio, $user_id]);
if ($result) {
$_SESSION['profile_update_success'] = true;
header("Location: profil.php");
exit;
} else {
$_SESSION['profile_update_success'] = false;
}
}
if (isset($_SESSION['profile_update_success'])) {
$success_message = $_SESSION['profile_update_success'];
unset($_SESSION['profile_update_success']);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Profile - Project Name</title>
<link rel="stylesheet" href="styles.css">
<script src="https://unpkg.com/lucide@latest"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
</head>
<body>
<nav class="navbar">
<div class="navbar-container">
<a href="index.php" class="navbar-brand">
<i data-lucide="triangle" style="width: 24px; height: 24px;"></i>
Project Name
</a>
<div class="profile-dropdown">
<button class="profile-button" onclick="toggleProfileMenu()">
<i data-lucide="user-circle" style="width: 20px; height: 20px;"></i>
<span><?= htmlspecialchars($user['full_name']); ?></span>
<i data-lucide="chevron-down" style="width: 16px; height: 16px;"></i>
</button>
<div class="profile-menu" id="profileMenu">
<a href="#" class="profile-menu-item">
<i data-lucide="user" style="width: 16px; height: 16px;"></i>
<span>Profile</span>
</a>
<a href="settings.php" class="profile-menu-item">
<i data-lucide="settings" style="width: 16px; height: 16px;"></i>
<span>Settings</span>
</a>
<div class="profile-menu-divider"></div>
<a href="logout.php" class="profile-menu-item">
<i data-lucide="log-out" style="width: 16px; height: 16px;"></i>
<span>Logout</span>
</a>
</div>
</div>
</div>
</nav>
<div class="main-content">
<div class="container">
<div class="dashboard-header">
<h1 class="dashboard-title">Profile</h1>
<p class="dashboard-subtitle">Manage your personal information and account settings.</p>
</div>
<div class="profile-section">
<div class="profile-avatar">
<img src="https://cdn.discordapp.com/attachments/1202572905947471946/1314910490215841872/user-circle.png?ex=67557d52&is=67542bd2&hm=d72756fefce02616c94205beeb491f047bbc06438fcb17409200baffcd330adb&" alt="Profile picture" class="avatar-image">
<button class="btn-secondary">Change Photo</button>
</div>
<form class="profile-form" method="POST" action="profil.php">
<div class="form-group-row">
<div class="form-group1">
<label class="form-label">Full Name</label>
<input type="text" name="full_name" class="form-input" value="<?= htmlspecialchars($user['full_name']); ?>" placeholder="Enter your full name" required>
</div>
</div>
<div class="form-group1">
<label class="form-label">Email</label>
<input type="email" name="email" class="form-input" value="<?= htmlspecialchars($user['email']); ?>" placeholder="Enter your email" required>
</div>
<div class="form-group1">
<label class="form-label">Bio</label>
<textarea name="bio" class="form-input" rows="4" placeholder="Tell us about yourself"><?= htmlspecialchars($user['bio']); ?></textarea>
</div>
<div class="form-actions">
<button type="submit" class="btn-primary">Save Changes</button>
<button type="button" class="btn-secondary">Cancel</button>
</div>
</form>
</div>
</div>
</div>
<script>
lucide.createIcons();
function toggleProfileMenu() {
const menu = document.getElementById('profileMenu');
menu.classList.toggle('active');
}
document.addEventListener('click', function(event) {
const dropdown = document.querySelector('.profile-dropdown');
const menu = document.getElementById('profileMenu');
if (!dropdown.contains(event.target)) {
menu.classList.remove('active');
}
});
<?php if (isset($success_message)) : ?>
Swal.fire({
icon: '<?= $success_message ? "success" : "error"; ?>',
title: '<?= $success_message ? "Profile Updated" : "Error"; ?>',
text: '<?= $success_message ? "Your profile has been updated successfully." : "There was a problem updating your profile."; ?>',
timer: 3000,
showConfirmButton: false
});
<?php endif; ?>
</script>
</body>
</html>