34 lines
1.0 KiB
PHP
34 lines
1.0 KiB
PHP
|
|
<?php
|
||
|
|
// /inc/php/view_email.php
|
||
|
|
session_start();
|
||
|
|
require_once($_SERVER['DOCUMENT_ROOT'] . '/inc/php/auth.php');
|
||
|
|
requireLogin();
|
||
|
|
|
||
|
|
require_once($_SERVER['DOCUMENT_ROOT'] . '/db.php');
|
||
|
|
$conn = getConnection();
|
||
|
|
|
||
|
|
$user_id = $_SESSION['user_id'] ?? null;
|
||
|
|
$id = intval($_GET['id'] ?? 0);
|
||
|
|
|
||
|
|
$stmt = $conn->prepare("SELECT subject, body, created_at FROM saved_emails WHERE id = ? AND user_id = ?");
|
||
|
|
$stmt->bind_param("ii", $id, $user_id);
|
||
|
|
$stmt->execute();
|
||
|
|
$result = $stmt->get_result();
|
||
|
|
$email = $result->fetch_assoc();
|
||
|
|
|
||
|
|
include($_SERVER['DOCUMENT_ROOT'] . '/inc/php/header.php');
|
||
|
|
?>
|
||
|
|
|
||
|
|
<body>
|
||
|
|
<div class="container">
|
||
|
|
<?php if ($email): ?>
|
||
|
|
<h1><?= htmlspecialchars($email['subject'] ?: '(No Subject)') ?></h1>
|
||
|
|
<p><em>Saved on <?= $email['created_at'] ?></em></p>
|
||
|
|
<pre><?= htmlspecialchars($email['body']) ?></pre>
|
||
|
|
<a href="/inc/php/saved.php"><button>⬅ Back</button></a>
|
||
|
|
<?php else: ?>
|
||
|
|
<p>Email not found ❌</p>
|
||
|
|
<?php endif; ?>
|
||
|
|
</div>
|
||
|
|
<?php include($_SERVER['DOCUMENT_ROOT'] . '/inc/php/footer.php'); ?>
|