<?php
include 'db_connection.php'; // Include your database connection

session_start();
$studentId = $_SESSION['student_id'];


// Prepare and execute the query to fetch profile information
$stmt = $conn->prepare("SELECT * FROM profiles WHERE student_id = ?");
$stmt->bind_param("i", $studentId);
$stmt->execute();
$result = $stmt->get_result();
$profile = $result->fetch_assoc();

// Close the statement and connection
$stmt->close();
$conn->close();

// Construct the path for the profile picture
$profilePicturePath = "/csms/student/uploads/" . $profile['profile_picture'];


?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Profile</title>
    <link rel="stylesheet" href="path/to/your/styles.css"> <!-- Ensure CSS path is correct -->
    <style type="text/css">
    .profile {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.profile img {
    border-radius: 50%;
    border: 2px solid #ddd;
    padding: 5px;
    margin-bottom: 20px;
}

.profile p {
    font-size: 18px;
    margin: 5px 0;
}

@media (max-width: 600px) {
    .profile {
        font-size: 14px;
    }
}

    </style>
</head>
<body>
    <h1>User Profile</h1>
    <div class="profile">
        <img src="<?php echo $profilePicturePath; ?>" alt="Profile Picture" style="max-width: 200px; height: auto;">
        <p>Name: <?php echo htmlspecialchars($profile['name']); ?></p>
        <p>Bio: <?php echo htmlspecialchars($profile['bio']); ?></p>
           <a href="edit_profile.php" class="edit-button">Edit Profile</a>
      </div>
</body>
</html>
