forked from xo-aria/account-system-php
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
37 lines (31 loc) · 1.04 KB
/
index.php
File metadata and controls
37 lines (31 loc) · 1.04 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
<?php
require_once 'function/db.php';
session_start();
// Redirect to login if user is not logged in
if (empty($_SESSION['user'])) {
header('Location: login.php');
exit();
}
// Fetch user data
$user = $_SESSION['user'];
$stmt = $conn->prepare("SELECT * FROM users WHERE user = :user");
$stmt->bindParam(':user', $user);
$stmt->execute();
$fetch = $stmt->fetch();
// Redirect to login if user is not found
if (!$fetch) {
header('Location: login.php');
exit();
}
require_once 'template/header.php';
?>
<div class="box">
<h2>سلام <?php echo htmlspecialchars($fetch['user'], ENT_QUOTES, 'UTF-8'); ?></h2>
<p>نام کاربری: <b><?php echo htmlspecialchars($fetch['user'], ENT_QUOTES, 'UTF-8'); ?></b></p>
<p>ایمیل: <b><?php echo htmlspecialchars($fetch['email'], ENT_QUOTES, 'UTF-8'); ?></b></p>
<p>شناسه: <b><?php echo htmlspecialchars($fetch['id'], ENT_QUOTES, 'UTF-8'); ?></b></p>
<a href="logout.php">خروج</a>
</div>
<?php
require_once 'template/footer.php';
?>