saved emails, gmail, hotmail start, home, landing etc

This commit is contained in:
Dr3amFury
2025-08-20 12:58:40 +02:00
parent 08a5cead74
commit 9ec1e0f9fe
17 changed files with 683 additions and 172 deletions

39
inc/php/save_email.php Normal file
View File

@@ -0,0 +1,39 @@
<?php
// /inc/php/save_email.php
session_start();
require_once($_SERVER['DOCUMENT_ROOT'] . '/inc/php/auth.php');
requireLogin(); // block guests
require_once($_SERVER['DOCUMENT_ROOT'] . '/db.php');
$conn = getConnection();
$user_id = $_SESSION['user_id'] ?? null;
if (!$user_id) {
die("Unauthorized. Please log in.");
}
// Get and sanitize inputs
$subject = trim($_POST['subject'] ?? '');
$email_body = trim($_POST['email_body'] ?? '');
if (empty($email_body)) {
die("No email content provided.");
}
$stmt = $conn->prepare("
INSERT INTO saved_emails (user_id, subject, body, created_at)
VALUES (:user_id, :subject, :body, NOW())
");
if ($stmt->execute([
':user_id' => $user_id,
':subject' => $subject,
':body' => $email_body
])) {
header("Location: /home.php?success=1");
exit;
} else {
$error = $stmt->errorInfo();
echo "Error saving email: " . $error[2];
}