saved emails, gmail, hotmail start, home, landing etc
This commit is contained in:
46
saved_emails.php
Normal file
46
saved_emails.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
// /saved_emails.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;
|
||||
|
||||
$stmt = $conn->prepare("
|
||||
SELECT id, subject, body, created_at
|
||||
FROM saved_emails
|
||||
WHERE user_id = :user_id
|
||||
ORDER BY created_at DESC
|
||||
");
|
||||
$stmt->execute([':user_id' => $user_id]);
|
||||
$emails = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
?>
|
||||
|
||||
<?php include($_SERVER['DOCUMENT_ROOT'] . '/inc/php/header.php'); ?>
|
||||
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>📑 Saved Emails</h1>
|
||||
|
||||
<?php if (!empty($emails)): ?>
|
||||
<table>
|
||||
<tr><th>Subject</th><th>Preview</th><th>Date</th><th>Action</th></tr>
|
||||
<?php foreach ($emails as $email): ?>
|
||||
<tr>
|
||||
<td><?= htmlspecialchars($email['subject'] ?: '(No Subject)') ?></td>
|
||||
<td><?= htmlspecialchars(substr($email['body'], 0, 50)) ?>...</td>
|
||||
<td><?= $email['created_at'] ?></td>
|
||||
<td>
|
||||
<a href="/view_email.php?id=<?= $email['id'] ?>"><button>View</button></a>
|
||||
<a href="/inc/php/delete_email.php?id=<?= $email['id'] ?>" onclick="return confirm('Delete this email?')"><button>Delete</button></a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
<?php else: ?>
|
||||
<p>No saved emails yet.</p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php include($_SERVER['DOCUMENT_ROOT'] . '/inc/php/footer.php'); ?>
|
||||
Reference in New Issue
Block a user