Mini Kabibi Habibi

Current Path : C:/xampp/htdocs/cid/system/
Upload File :
Current File : C:/xampp/htdocs/cid/system/fetch_report.php

<?php
session_start();
@include 'include/config.php';

if (!isset($_SESSION['username_school'])) {
    echo "Unauthorized access.";
    exit;
}

$username = $_SESSION['username_school'];

if (!isset($_POST['id'])) {
    echo "Missing report ID.";
    exit;
}

$id = intval($_POST['id']);
$stmt = $conn->prepare("SELECT * FROM monthly_accomplishments WHERE id = ? AND username = ?");
$stmt->bind_param("is", $id, $username);
$stmt->execute();
$result = $stmt->get_result();

if ($result->num_rows === 0) {
    echo "Report not found.";
    exit;
}

$report = $result->fetch_assoc();
?>

<p><strong>Title:</strong> <?php echo htmlspecialchars($report['title']); ?></p>
<p><strong>Date Submitted:</strong> <?php echo htmlspecialchars($report['date_added']); ?></p>
<p><strong>Designation:</strong> <?php echo htmlspecialchars($report['designation']); ?></p>

<?php if (!empty($report['file_path'])): ?>
    <iframe src="<?php echo htmlspecialchars($report['file_path']); ?>" width="100%" height="500px" style="border: 1px solid #ccc;"></iframe>
<?php else: ?>
    <p><em>No file uploaded for this report.</em></p>
<?php endif; ?>