AIPT/cms_admin/container/security.php
2024-10-29 03:42:53 +00:00

24 lines
602 B
PHP

<?php
session_start(); // Start the session
// Redirect to login page if the user is not logged in
if (!isset($_SESSION['user_id'])) {
header("Location: sign-in");
exit();
}
include 'db_connection.php';
// Fetch the user's data from the database
$user_id = $_SESSION['user_id'];
$sql = "SELECT * FROM users WHERE id = $user_id";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
$user = mysqli_fetch_assoc($result);
} else {
echo "User not found.";
exit();
}
?>