<?php
session_start();
include('db_connection.php');

if (!isset($_SESSION['teacher_id'])) {
    header("Location: teacher_login.php");
    exit();
}

$teacher_id = $_SESSION['teacher_id'];
$id = intval($_GET['id']);

$sql = "SELECT * FROM payrolls WHERE id = ? AND teacher_id = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("ii", $id, $teacher_id);
$stmt->execute();
$result = $stmt->get_result();
$p = $result->fetch_assoc();

if (!$p) {
    die("Payslip not found.");
}
?>