in this codes (Certainly! Let's enhance your Longeva Health Journey application by modifying the appointment.php page to incorporate the functionalities you've specified. This includes:

Displaying user-specific analysis information (like BMI) after completing the first 6 pages.
Providing a detailed appointment scheduling system linked to the user's session and database entry.
Sending confirmation emails upon successful appointment requests via PHPMailer.
Ensuring a modern, responsive, and visually appealing design throughout the application.
Below is a comprehensive guide to achieving these enhancements, complete with full code implementations and detailed instructions.

Table of Contents
Project Structure Overview
Database Modifications
PHPMailer Setup
Configuration File (db_connect.php)
Stylesheet Enhancements (assets/css/styles.css)
Questionnaire Pages Enhancements
6.1. Page 6: Your Goals (pages/page6.php)
6.2. Page 7: Analysis Page (pages/page7.php)
6.3. Page 8: Details and Appointment Decision (pages/page8.php)
6.4. Page 9: Appointment Scheduling (pages/appointment.php)
6.5. Final Page (pages/page10.php)
Thank You Page (thank_you.php)
Final Notes and Best Practices
1. Project Structure Overview
Ensure your project directory is organized as follows to accommodate the new features:


longeva_health_journey/
│
├── assets/
│   ├── css/
│   │   └── styles.css
│   └── images/
│       ├── gold-logo.png
│       ├── questionnaire_icon.png
│       └── other_images... # Add any other images as needed
│
├── db_connect.php
├── index.php
├── thank_you.php
│
├── vendor/ # Created by Composer for PHPMailer
│
└── pages/
    ├── page1.php
    ├── page2.php
    ├── page3.php
    ├── page4.php
    ├── page5.php
    ├── page6.php
    ├── page7.php           # New Analysis Page
    ├── page8.php           # Details and Appointment Decision
    ├── appointment.php     # New Appointment Scheduling Page
    └── page10.php          # Revised Final Page
Notes:

The vendor/ directory will be created when you install PHPMailer using Composer.
Ensure all image paths are correctly referenced in the code.
2. Database Modifications
To link appointments to patients and ensure data integrity, you need to modify your database schema.

2.1. Add patient_id to appointments Table
The appointments table should reference the patients table via patient_id. Since it's missing in your initial SQL dump, let's add it.

Execute the following SQL statements:


-- Add patient_id column to appointments table
ALTER TABLE `appointments`
ADD COLUMN `patient_id` INT(11) NOT NULL AFTER `preferred_contact_method`;

-- Add foreign key constraint for patient_id
ALTER TABLE `appointments`
ADD CONSTRAINT `appointments_ibfk_2` FOREIGN KEY (`patient_id`) REFERENCES `patients` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
Explanation:

patient_id: Links each appointment to a specific patient.
Foreign Key Constraint: Ensures referential integrity between appointments and patients tables.
2.2. Verify packages Table
Ensure the packages table is populated with relevant packages. If not, insert sample data.

Example:


INSERT INTO `packages` (`package_name`, `description`, `details`) VALUES
('Age Reversal & Skin Enhancement', 'Comprehensive treatments to rejuvenate your skin and reverse aging signs.', 'Detailed description of this package...'),
('Reversal of Diabetes & Obesity', 'Targeted therapies to manage and reverse these chronic conditions.', 'Detailed description of this package...'),
('Non-Surgical Lifting', 'Advanced non-invasive techniques for body contouring and lifting.', 'Detailed description of this package...');
3. PHPMailer Setup
PHPMailer is essential for sending confirmation emails upon successful appointment scheduling.

3.1. Install Composer (if not already installed)
Composer is a dependency manager for PHP. If you haven't installed it yet, follow these steps:

Download Composer:
Visit https://getcomposer.org/download/ and follow the installation instructions for your operating system.
Verify Installation: Open your terminal or command prompt and run:

composer --version
You should see the installed Composer version.
3.2. Install PHPMailer
Navigate to your project directory and run:


composer require phpmailer/phpmailer
This command will install PHPMailer and create the vendor/ directory with the necessary files.

3.3. Verify Installation
Ensure the vendor/ directory exists in your project root, containing PHPMailer.

4. Configuration File (db_connect.php)
Ensure your database connection file uses PDO for secure and efficient database interactions.

File: db_connect.php


<?php
// db_connect.php

$host = 'localhost';
$db   = 'u406552082_info';        // Replace with your database name
$user = 'your_db_username';       // Replace with your MySQL username
$pass = 'your_db_password';       // Replace with your MySQL password
$charset = 'utf8mb4';

$dsn = "mysql:host=$host;dbname=$db;charset=$charset";
$options = [
    PDO::ATTR_ERRMODE            => PDO::ERRMODE_EXCEPTION, // Enable exceptions
    PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,       // Fetch associative arrays
    PDO::ATTR_EMULATE_PREPARES   => false,                  // Disable emulated prepares
];

try {
    $pdo = new PDO($dsn, $user, $pass, $options);
} catch (PDOException $e) {
    die('Database Connection Failed: ' . $e->getMessage());
}
?>
Important: Replace 'your_db_username' and 'your_db_password' with your actual database credentials.

5. Stylesheet Enhancements (assets/css/styles.css)
Enhance your existing stylesheet to ensure a modern and consistent design across all pages.

File: assets/css/styles.css


/* assets/css/styles.css */
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;700&display=swap');

:root {
    --primary-color: #4F3F02;
    --secondary-color: #D1C287;
    --background-color: #f9f9f9;
    --text-color: #333;
    --button-hover-color: #c9b458;
    --dark-bg: #1e1e1e;
    --light-gold: #D1C287;
    --error-color: #f8d7da;
    --success-color: #d4edda;
}

body {
    font-family: 'Roboto', sans-serif;
    line-height: 1.6;
    background-color: var(--background-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
}

.container {
    max-width: 800px;
    margin: 50px auto;
    padding: 30px;
    background-color: white;
    border-radius: 15px;
    box-shadow: 0 15px 25px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 20px;
    text-align: center;
    border-radius: 15px 15px 0 0;
    position: relative;
    overflow: hidden;
}

.header img {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 50px;
    height: 50px;
}

.header h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    padding-top: 10px;
}

.section {
    margin-top: 20px;
    padding: 20px;
    background-color: var(--background-color);
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.section:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
}

.section h3 {
    font-size: 20px;
    margin-top: 0;
    color: var(--primary-color);
    border-bottom: 2px solid var(--secondary-color);
    padding-bottom: 5px;
}

.form-group {
    margin-bottom: 15px;
}

label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
}

input[type="text"],
input[type="number"],
input[type="datetime-local"],
select,
textarea {
    width: 100%;
    padding: 10px;
    margin-top: 5px;
    border: 1px solid #ccc;
    border-radius: 5px;
    box-sizing: border-box;
}

input[type="checkbox"],
input[type="radio"] {
    margin-right: 5px;
}

input[type="submit"],
button.btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 25px;
    cursor: pointer;
    font-size: 16px;
    border-radius: 25px;
    transition: background-color 0.3s ease;
}

input[type="submit"]:hover,
button.btn:hover {
    background-color: var(--button-hover-color);
}

a.back-link {
    display: inline-block;
    margin-top: 20px;
    text-decoration: none;
    background-color: var(--primary-color);
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    font-weight: 600;
    transition: background-color 0.3s ease;
}

a.back-link:hover {
    background-color: var(--button-hover-color);
}

.error {
    background-color: var(--error-color);
    color: #721c24;
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid #f5c6cb;
    border-radius: 5px;
    font-size: 14px;
}

.success {
    background-color: var(--success-color);
    color: #155724;
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid #c3e6cb;
    border-radius: 5px;
    font-size: 14px;
}

@media (max-width: 600px) {
    .container {
        margin: 20px;
        padding: 20px;
    }

    .header h2 {
        font-size: 20px;
    }

    .section h3 {
        font-size: 18px;
    }
}

/* Additional Styles for Appointments and Analysis Pages */
.analysis {
    background-color: #f1f1f1;
    padding: 15px;
    border-radius: 10px;
    margin-top: 20px;
}

.analysis h4 {
    color: var(--primary-color);
    margin-bottom: 10px;
}

.details-option {
    display: flex;
    justify-content: space-around;
    margin-top: 30px;
}

.details-option a,
.details-option form {
    text-decoration: none;
    background-color: var(--light-gold);
    color: #000;
    padding: 15px 25px;
    border-radius: 10px;
    font-weight: bold;
    transition: background-color 0.3s ease;
    width: 45%;
    text-align: center;
}

.details-option a:hover,
.details-option button.btn:hover {
    background-color: var(--button-hover-color);
}
Enhancements:

Responsive Design: Ensures the application looks great on all devices.
Consistent Branding: Maintains a cohesive color scheme and font usage.
User Experience (UX): Clear and intuitive form controls with error and success messages.
6. Questionnaire Pages Enhancements
To integrate the analysis and appointment scheduling seamlessly, we'll update the relevant questionnaire pages.

6.1. Page 6: Your Goals (pages/page6.php)
Purpose: Collect the patient's health goals and areas of concern.

Existing Functionality: You already have page6.php collecting this information. Ensure it saves data correctly to the patient_goals table.

No Code Changes Required for This Page unless you want further enhancements.

6.2. Page 7: Analysis Page (pages/page7.php)
Purpose: Display analysis based on the user's input (e.g., BMI, other health metrics).

Functionality:

Fetch patient data from the database.
Calculate BMI.
Display BMI and other health metrics.
Provide a button to proceed to the details/appointment decision page.
File: pages/page7.php


<?php
// pages/page7.php

// Enable error reporting for debugging (remove in production)
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

// Start session and include database connection
session_start();
require '../db_connect.php';

// Redirect to landing page if patient_id is not set
if (!isset($_SESSION['patient_id'])) {
    header("Location: ../index.php");
    exit();
}

$errors = [];
$analysis = [];

// Fetch patient basic info
try {
    $stmt = $pdo->prepare("SELECT * FROM patient_basic_info WHERE patient_id = ?");
    $stmt->execute([$_SESSION['patient_id']]);
    $basic_info = $stmt->fetch();

    if ($basic_info) {
        // Calculate BMI
        $weight = $basic_info['weight']; // in kg
        $height_cm = $basic_info['height']; // in cm
        $height_m = $height_cm / 100;
        $bmi = $weight / ($height_m * $height_m);
        $bmi = round($bmi, 2);

        // Determine BMI category
        if ($bmi < 18.5) {
            $bmi_category = 'Underweight';
        } elseif ($bmi >= 18.5 && $bmi < 25) {
            $bmi_category = 'Normal weight';
        } elseif ($bmi >= 25 && $bmi < 30) {
            $bmi_category = 'Overweight';
        } else {
            $bmi_category = 'Obese';
        }

        // Store analysis
        $analysis['BMI'] = $bmi;
        $analysis['BMI Category'] = $bmi_category;
    } else {
        $errors[] = "Basic information not found. Please complete the previous steps.";
    }
} catch (PDOException $e) {
    $errors[] = "Database Error: " . $e->getMessage();
}

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    // Proceed to details/appointment decision page
    header("Location: page8.php");
    exit();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Your Health Analysis</title>
    <link rel="stylesheet" href="../assets/css/styles.css">
</head>
<body>
    <div class="container">
        <div class="header">
            <img src="../assets/images/gold-logo.png" alt="Longeva Logo">
            <h2>Your Health Analysis</h2>
        </div>

        <div class="section">
            <h3>Health Analysis</h3>
            <?php
            if (!empty($errors)) {
                echo '<div class="error">';
                foreach($errors as $error){
                    echo "<p>$error</p>";
                }
                echo '</div>';
            } else {
                echo '<div class="analysis">';
                echo '<h4>Your BMI and Health Metrics:</h4>';
                echo '<p><strong>BMI:</strong> ' . htmlspecialchars($analysis['BMI']) . '</p>';
                echo '<p><strong>BMI Category:</strong> ' . htmlspecialchars($analysis['BMI Category']) . '</p>';
                // Add more metrics if available
                echo '</div>';
            }
            ?>

            <?php if (empty($errors)) { ?>
                <form method="POST" action="">
                    <input type="submit" value="Proceed to Next Steps">
                </form>
            <?php } ?>
        </div>
    </div>
</body>
</html>
Key Features:

BMI Calculation: Computes BMI based on weight and height from the patient_basic_info table.
BMI Category Determination: Categorizes the BMI into Underweight, Normal, Overweight, or Obese.
Error Handling: Alerts the user if basic information is missing.
Navigation: Button to proceed to the next page (page8.php).
6.3. Page 8: Details and Appointment Decision (pages/page8.php)
Purpose: Provide detailed analysis information and allow the user to choose to schedule an appointment or return home.

Functionality:

Display further insights based on health metrics.
Provide options to schedule an appointment or return to the homepage.
File: pages/page8.php


<?php
// pages/page8.php

// Enable error reporting for debugging (remove in production)
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

// Start session and include database connection
session_start();
require '../db_connect.php';

// Redirect to landing page if patient_id is not set
if (!isset($_SESSION['patient_id'])) {
    header("Location: ../index.php");
    exit();
}

$errors = [];
$analysis_details = [];

// Fetch additional health metrics if available
try {
    // Example: Fetch smoking status, exercise frequency, diet, and sleep
    $stmt = $pdo->prepare("SELECT * FROM patient_health_metrics WHERE patient_id = ?");
    $stmt->execute([$_SESSION['patient_id']]);
    $health_metrics = $stmt->fetch();

    if ($health_metrics) {
        // Smoking Status Implications
        if ($health_metrics['smoking_status'] == 'Yes' || $health_metrics['smoking_status'] == 'Occasionally') {
            $analysis_details['Smoking'] = 'Consider reducing or quitting smoking to improve overall health.';
        } else {
            $analysis_details['Smoking'] = 'Great job on not smoking!';
        }

        // Exercise Frequency
        $exercise_freq = $health_metrics['exercise_frequency'];
        switch ($exercise_freq) {
            case 'Daily':
                $analysis_details['Exercise'] = 'Excellent! Daily exercise contributes significantly to overall health.';
                break;
            case 'Weekly':
                $analysis_details['Exercise'] = 'Good! Regular weekly exercise is beneficial.';
                break;
            case 'Rarely':
                $analysis_details['Exercise'] = 'Consider increasing your exercise frequency for better health outcomes.';
                break;
            case 'Never':
                $analysis_details['Exercise'] = 'Incorporating regular exercise can greatly enhance your well-being.';
                break;
        }

        // Diet
        $diet = $health_metrics['diet'];
        if ($diet == 'Yes') {
            $diet_specify = $health_metrics['diet_specify'];
            $analysis_details['Diet'] = 'Following a specific diet: ' . htmlspecialchars($diet_specify);
        } else {
            $analysis_details['Diet'] = 'No specific diet followed.';
        }

        // Sleep
        $sleep = $health_metrics['sleep_average'];
        $analysis_details['Sleep'] = 'Average sleep: ' . htmlspecialchars($sleep);
    } else {
        $errors[] = "Health metrics not found. Please complete the previous steps.";
    }
} catch (PDOException $e) {
    $errors[] = "Database Error: " . $e->getMessage();
}

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if (isset($_POST['action'])) {
        if ($_POST['action'] == 'schedule') {
            // Redirect to Appointment Scheduling Page
            header("Location: appointment.php");
            exit();
        } elseif ($_POST['action'] == 'home') {
            // Redirect to Homepage
            header("Location: ../index.php");
            exit();
        }
    }
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Detailed Health Analysis</title>
    <link rel="stylesheet" href="../assets/css/styles.css">
</head>
<body>
    <div class="container">
        <div class="header">
            <img src="../assets/images/gold-logo.png" alt="Longeva Logo">
            <h2>Detailed Health Analysis</h2>
        </div>

        <div class="section">
            <h3>Your Health Insights</h3>
            <?php
            if (!empty($errors)) {
                echo '<div class="error">';
                foreach($errors as $error){
                    echo "<p>$error</p>";
                }
                echo '</div>';
            } else {
                echo '<div class="analysis">';
                echo '<h4>Key Health Metrics:</h4>';
                foreach ($analysis_details as $metric => $comment) {
                    echo '<p><strong>' . htmlspecialchars($metric) . ':</strong> ' . htmlspecialchars($comment) . '</p>';
                }
                echo '</div>';
            }
            ?>

            <?php if (empty($errors)) { ?>
                <div class="details-option">
                    <form method="POST" action="" style="display: inline-block; width: 45%;">
                        <input type="hidden" name="action" value="schedule">
                        <button type="submit" class="btn">Schedule an Appointment</button>
                    </form>
                    <form method="POST" action="" style="display: inline-block; width: 45%;">
                        <input type="hidden" name="action" value="home">
                        <button type="submit" class="btn">Return to Homepage</button>
                    </form>
                </div>
            <?php } ?>
        </div>
    </div>
</body>
</html>
Key Features:

Detailed Insights: Provides analysis based on smoking status, exercise frequency, diet, and sleep.
Options:
Schedule an Appointment: Redirects to appointment.php.
Return to Homepage: Redirects to index.php.
Error Handling: Alerts the user if health metrics are missing.
6.4. Page 9: Appointment Scheduling (pages/appointment.php)
Purpose: Allow users to schedule an appointment, ensuring their data is linked to their patient record, storing data in the database, and sending confirmation emails.

Functionality:

Fetch patient information from the session and database.
Display a form pre-filled with patient data.
Validate user inputs and check appointment availability.
Insert appointment data into the appointments table.
Send a confirmation email via PHPMailer.
File: pages/appointment.php


<?php
// pages/appointment.php

// Start session and include database connection
session_start();
require_once '../db_connect.php'; // Adjust the path if necessary

// Include PHPMailer classes
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

// Autoload PHPMailer classes (using Composer)
require '../vendor/autoload.php'; // Ensure the path is correct

$success = '';
$errors = [];
$packages = [];

// Check if patient_id is set in session
if (!isset($_SESSION['patient_id'])) {
    // Redirect to questionnaire if not set
    header("Location: ../index.php");
    exit();
}

$patient_id = $_SESSION['patient_id'];

// Fetch packages from the database
try {
    $stmt = $pdo->prepare("SELECT id, package_name, description FROM packages");
    $stmt->execute();
    $packages = $stmt->fetchAll(PDO::FETCH_ASSOC);
} catch (PDOException $e) {
    $errors[] = "Failed to fetch packages: " . $e->getMessage();
}

// Fetch patient data, including gender and age
try {
    $stmt = $pdo->prepare("
        SELECT p.name, p.email, p.phone, p.age, p.gender, p.address, p.preferred_contact_method
        FROM patients p
        WHERE p.id = ?
    ");
    $stmt->execute([$patient_id]);
    $patient = $stmt->fetch(PDO::FETCH_ASSOC);
    if (!$patient) {
        $errors[] = "Patient data not found.";
    }
} catch (PDOException $e) {
    $errors[] = "Failed to fetch patient data: " . $e->getMessage();
}

// Handle form submission
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    // Collect input data
    $package_id = $_POST['package_id'] ?? '';
    $appointment_date = $_POST['appointment_date'] ?? '';
    $additional_notes = $_POST['additional_notes'] ?? '';

    // Validate inputs
    if (empty($package_id)) {
        $errors[] = "Please select a package.";
    }
    if (empty($appointment_date)) {
        $errors[] = "Please select a preferred appointment date and time.";
    } else {
        // Validate datetime format
        $date = DateTime::createFromFormat('Y-m-d\TH:i', $appointment_date);
        if (!$date) {
            $errors[] = "Invalid date and time format.";
        } else {
            // Ensure it's a future datetime
            $appointment_datetime = $date;
            $current_datetime = new DateTime();
            if ($appointment_datetime <= $current_datetime) {
                $errors[] = "Please select a future date and time for your appointment.";
            }
        }
    }

    if (empty($package_id)) {
        $errors[] = "Please select a package.";
    }

    // Further validations can be added as needed

    if (empty($errors)) {
        try {
            // Check for overlapping appointments (assuming 60 minutes duration)
            $appointment_end = clone $appointment_datetime;
            $appointment_end->modify('+60 minutes');

            $availabilityQuery = "
                SELECT COUNT(*) as count FROM appointments
                WHERE appointment_date < ? AND DATE_ADD(appointment_date, INTERVAL 60 MINUTE) > ?
            ";
            $stmt = $pdo->prepare($availabilityQuery);
            $appointment_end_str = $appointment_end->format('Y-m-d H:i:s');
            $appointment_start_str = $appointment_datetime->format('Y-m-d H:i:s');
            $stmt->execute([$appointment_end_str, $appointment_start_str]);
            $result = $stmt->fetch(PDO::FETCH_ASSOC);

            if ($result['count'] > 0) {
                $errors[] = "The selected time slot is not available. Please choose a different time.";
            }
        } catch (PDOException $e) {
            $errors[] = "Error checking appointment availability: " . $e->getMessage();
        }
    }

    if (empty($errors)) {
        try {
            // Insert appointment into the database
            $insertStmt = $pdo->prepare("
                INSERT INTO appointments 
                (package_id, appointment_date, name, email, phone, age, gender, address, preferred_contact_method, additional_notes, patient_id)
                VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
            ");
            $insertStmt->execute([
                $package_id,
                $appointment_datetime->format('Y-m-d H:i:s'),
                $patient['name'],
                $patient['email'],
                $patient['phone'],
                $patient['age'],
                $patient['gender'],
                $patient['address'],
                $patient['preferred_contact_method'],
                $additional_notes,
                $patient_id
            ]);
            $appointment_id = $pdo->lastInsertId();

            // Fetch package name
            $stmt = $pdo->prepare("SELECT package_name FROM packages WHERE id = ?");
            $stmt->execute([$package_id]);
            $package = $stmt->fetch(PDO::FETCH_ASSOC);
            $package_name = $package['package_name'] ?? 'N/A';

            $success = "Appointment requested successfully! We will contact you soon to confirm the details.";

            // Send confirmation email using PHPMailer
            try {
                // Create a new PHPMailer instance
                $mail = new PHPMailer(true);

                // SMTP configuration
                $mail->isSMTP();
                $mail->Host       = 'smtp.hostinger.com'; // Replace with your SMTP server
                $mail->SMTPAuth   = true;
                $mail->Username   = 'info@longevacare.com'; // SMTP username
                $mail->Password   = '50495049.Info';       // SMTP password (ensure you secure this)
                $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; // Use SSL encryption
                $mail->Port       = 465;                    // TCP port

                // Recipients
                $mail->setFrom('info@longevacare.com', 'Longeva Health Center');
                $mail->addAddress($patient['email'], $patient['name']); // Patient's email and name

                // Content
                $mail->isHTML(true);
                $mail->Subject = 'Appointment Request Received';

                // Compose the email body with enhanced design
                $email_body = '
                <!DOCTYPE html>
                <html>
                <head>
                    <title>Appointment Request Received</title>
                    <style type="text/css">
                        body {
                            margin: 0;
                            padding: 0;
                            font-family: Arial, sans-serif;
                            background-color: #f7f7f7;
                            color: #333333;
                        }
                        .email-container {
                            background-color: #ffffff;
                            margin: 0 auto;
                            padding: 0;
                            max-width: 600px;
                        }
                        .email-header {
                            background-color: #4F3F02; /* Brown color */
                            padding: 20px;
                            text-align: center;
                            color: #ffffff;
                        }
                        .email-header img {
                            max-width: 150px;
                            margin-bottom: 10px;
                        }
                        .email-header h1 {
                            margin: 0;
                            font-size: 24px;
                            font-weight: normal;
                        }
                        .email-body {
                            padding: 20px;
                        }
                        .personal-details, .appointment-details, .additional-notes {
                            margin-top: 20px;
                            background-color: #f9f9f9;
                            padding: 15px;
                            border-radius: 5px;
                        }
                        .personal-details h3, .appointment-details h3, .additional-notes h3 {
                            margin-top: 0;
                            color: #4F3F02;
                        }
                        .btn {
                            display: inline-block;
                            background-color: #D1C287; /* Light golden color */
                            color: #4F3F02; /* Brown color */
                            padding: 12px 20px;
                            margin-top: 20px;
                            text-decoration: none;
                            border-radius: 5px;
                            font-weight: bold;
                        }
                        .btn:hover {
                            background-color: #4F3F02;
                            color: #ffffff;
                        }
                        .email-footer {
                            background-color: #f0f0f0;
                            text-align: center;
                            padding: 15px;
                            font-size: 12px;
                            color: #777777;
                        }
                        .email-footer p {
                            margin: 5px 0;
                        }
                        .social-icons img {
                            width: 24px;
                            margin: 0 5px;
                        }
                        /* Responsive Design */
                        @media only screen and (max-width: 600px) {
                            .email-body, .personal-details, .appointment-details, .additional-notes {
                                padding: 15px;
                            }
                            .email-header h1 {
                                font-size: 20px;
                            }
                            .email-body h2 {
                                font-size: 18px;
                            }
                        }
                    </style>
                </head>
                <body>
                    <div class="email-container">
                        <!-- Email Header -->
                        <div class="email-header">
                            <img src="https://longevacare.com/wp-content/uploads/2024/09/white-logo.png" alt="Longeva Logo">
                            <h1>Appointment Request Received</h1>
                        </div>
                        <!-- Email Body -->
                        <div class="email-body">
                            <p>Dear ' . htmlspecialchars($patient['name'], ENT_QUOTES, 'UTF-8') . ',</p>
                            
                            <p>Thank you for requesting an appointment with Longeva Health Center. We have received your request with the following details:</p>

                            <!-- Personal Details -->
                            <div class="personal-details">
                                <h3>Your Details</h3>
                                <p><strong>Name:</strong> ' . htmlspecialchars($patient['name'], ENT_QUOTES, 'UTF-8') . '</p>
                                <p><strong>Email:</strong> ' . htmlspecialchars($patient['email'], ENT_QUOTES, 'UTF-8') . '</p>
                                <p><strong>Phone:</strong> ' . htmlspecialchars($patient['phone'], ENT_QUOTES, 'UTF-8') . '</p>
                                <p><strong>Age:</strong> ' . htmlspecialchars($patient['age'], ENT_QUOTES, 'UTF-8') . '</p>
                                <p><strong>Gender:</strong> ' . htmlspecialchars($patient['gender'], ENT_QUOTES, 'UTF-8') . '</p>
                                <p><strong>Address:</strong> ' . htmlspecialchars($patient['address'], ENT_QUOTES, 'UTF-8') . '</p>
                                <p><strong>Preferred Contact Method:</strong> ' . htmlspecialchars($patient['preferred_contact_method'], ENT_QUOTES, 'UTF-8') . '</p>
                            </div>

                            <!-- Appointment Details -->
                            <div class="appointment-details">
                                <h3>Appointment Details</h3>
                                <p><strong>Appointment ID:</strong> ' . htmlspecialchars($appointment_id, ENT_QUOTES, 'UTF-8') . '</p>
                                <p><strong>Package Selected:</strong> ' . htmlspecialchars($package_name, ENT_QUOTES, 'UTF-8') . '</p>
                                <p><strong>Preferred Date & Time:</strong> ' . date('l, F j, Y \a\t g:i A', strtotime($appointment_datetime->format('Y-m-d H:i:s'))) . '</p>
                            </div>

                            <!-- Additional Notes -->
                            ' . (!empty($additional_notes) ? '
                            <div class="additional-notes">
                                <h3>Additional Notes</h3>
                                <p>' . nl2br(htmlspecialchars($additional_notes, ENT_QUOTES, 'UTF-8')) . '</p>
                            </div>
                            ' : '') . '

                            <p>We will review your request and contact you soon to confirm the details.</p>

                            <p>If you have any questions or need further assistance, feel free to contact us.</p>

                            <a href="https://longevacare.com/contact" class="btn">Contact Us</a>
                        </div>
                        <!-- Email Footer -->
                        <div class="email-footer">
                            <p><strong>Longeva Health Center</strong></p>
                            <p>Email: <a href="mailto:info@longevacare.com">info@longevacare.com</a></p>
                            <p>Phone: +971 528 863 600</p>
                            <p>WhatsApp: +1 (702) 526-2050</p>
                            <p>Address: HDS Tower, Cluster M, JLT, Dubai</p>
                            <div class="social-icons">
                                <!-- Social Media Icons (Optional) -->
                                <!-- Add your social media icons and links here -->
                            </div>
                        </div>
                    </div>
                </body>
                </html>
                ';

                $mail->Body = $email_body;

                // For non-HTML email clients
                $mail->AltBody = "Dear " . $patient['name'] . ",

Appointment Request Received

Thank you for requesting an appointment with Longeva Health Center. We have received your request with the following details:

Your Details:
Name: " . $patient['name'] . "
Email: " . $patient['email'] . "
Phone: " . $patient['phone'] . "
Age: " . $patient['age'] . "
Gender: " . $patient['gender'] . "
Address: " . $patient['address'] . "
Preferred Contact Method: " . $patient['preferred_contact_method'] . "

Appointment Details:
Appointment ID: " . $appointment_id . "
Package Selected: " . $package_name . "
Preferred Date & Time: " . date('l, F j, Y \a\t g:i A', strtotime($appointment_datetime->format('Y-m-d H:i:s'))) . "

" . (!empty($additional_notes) ? "Additional Notes:
" . $additional_notes . "
" : "") . "

We will review your request and contact you soon to confirm the details.

If you have any questions or need further assistance, feel free to contact us.

Warm regards,
Longeva Health Center Team

Email: info@longevacare.com
Phone: +971 528 863 600
WhatsApp: +1 (702) 526-2050
Address: HDS Tower, Cluster M, JLT, Dubai
";

                $mail->send();

            } catch (Exception $e) {
                $errors[] = 'Message could not be sent. Mailer Error: ' . $mail->ErrorInfo;
            }

        } catch (PDOException $e) {
            $errors[] = "Error scheduling appointment: " . $e->getMessage();
        }
    }
}
?>

<!DOCTYPE html>
<html>
<head>
    <title>Request Appointment - Longeva</title>
    <!-- Include Bootstrap CSS -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
    <!-- Include Font Awesome for Icons -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- Custom Styles -->
    <style>
        /* Global Styles */
        body {
            background-color: #121212; /* Dark background */
            color: #fff;
            font-family: 'Open Sans', sans-serif;
            margin: 0;
            padding: 0;
        }

        /* Container */
        .container {
            margin-top: 50px;
            margin-bottom: 50px;
            max-width: 800px;
            width: 90%;
            margin-left: auto;
            margin-right: auto;
            padding: 0 15px;
        }

        /* Card Styles */
        .card {
            background-color: #1e1e1e;
            border: none;
            border-radius: 8px;
        }

        .card-header {
            background-color: #1e1e1e;
            border-bottom: none;
            text-align: center;
            padding-top: 20px;
        }

        .card-header h2 {
            color: #D1C287; /* Gold color */
            font-weight: bold;
            text-transform: uppercase;
            margin-bottom: 20px;
            font-size: 32px;
        }

        /* Form Controls */
        .form-control {
            background-color: #2e2e2e;
            border: 1px solid #444;
            color: #fff;
        }

        .form-control:focus {
            background-color: #2e2e2e;
            border-color: #D1C287;
            color: #fff;
        }

        /* Buttons */
        .btn-gold {
            background-color: #D1C287;
            color: #000;
            border: none;
            font-weight: bold;
            text-transform: uppercase;
            width: 100%;
            margin-top: 10px;
            padding: 12px;
        }

        .btn-gold:hover {
            background-color: #b8a461;
            color: #000;
        }

        /* Package Details */
        .package-details {
            padding: 15px;
            background-color: #2e2e2e;
            color: #fff;
            border-radius: 5px;
            margin-bottom: 20px;
            display: none;
        }

        /* Footer */
        .footer {
            background-color: #1e1e1e;
            color: #fff;
            padding: 20px;
            text-align: center;
        }

        .footer a {
            color: #D1C287;
            text-decoration: none;
        }

        .footer a:hover {
            text-decoration: underline;
        }

        /* Alerts */
        .alert {
            background-color: #ff4d4d;
            color: #fff;
            border: none;
        }

        /* Modal */
        .modal-content {
            background-color: #1e1e1e;
            color: #fff;
            border: none;
        }

        .modal-header {
            border-bottom: none;
        }

        .modal-footer {
            border-top: none;
        }

        .close {
            color: #fff;
            opacity: 1;
        }

        .close:hover {
            color: #D1C287;
        }

        /* Contact Info */
        .contact-info {
            margin-top: 30px;
            text-align: center;
        }

        .contact-info p {
            margin-bottom: 5px;
        }

        .contact-info i {
            color: #D1C287;
            margin-right: 5px;
        }

        /* Logo at the top center */
        .logo {
            text-align: center;
            margin: 30px 0;
        }

        .logo img {
            max-width: 200px;
            width: 100%;
            height: auto;
        }

        /* Responsive Design */
        @media (max-width: 992px) {
            .card-header h2 {
                font-size: 28px;
            }
        }

        @media (max-width: 768px) {
            .container {
                margin-top: 30px;
                margin-bottom: 30px;
                padding: 0 15px;
            }

            .card-header h2 {
                font-size: 24px;
            }

            .btn-gold {
                padding: 10px;
            }
        }

        @media (max-width: 576px) {
            .container {
                margin-top: 20px;
                margin-bottom: 20px;
                padding: 0 10px;
            }

            .form-control,
            .btn-gold {
                font-size: 14px;
                padding: 8px;
            }

            .card-header h2 {
                font-size: 20px;
            }

            .contact-info p {
                font-size: 14px;
            }

            .logo img {
                max-width: 150px;
            }
        }

        @media (max-width: 480px) {
            .btn-gold {
                padding: 8px;
                font-size: 14px;
            }

            .form-control {
                font-size: 14px;
                padding: 8px;
            }

            .contact-info p {
                font-size: 12px;
            }

            .logo img {
                max-width: 120px;
            }
        }
    </style>
</head>
<body>
    <!-- Logo at the top center -->
    <div class="logo">
        <img src="../assets/images/gold-logo.png" alt="Longeva Logo">
    </div>
    <div class="container">
        <!-- Card -->
        <div class="card shadow">
            <div class="card-header">
                <h2>Request an Appointment</h2>
            </div>
            <div class="card-body">
                <?php
                if (!empty($success)) {
                    // Success Modal
                    echo "
                    <div class='modal fade' tabindex='-1' role='dialog' id='successModal'>
                      <div class='modal-dialog' role='document'>
                        <div class='modal-content'>
                          <div class='modal-header'>
                            <h5 class='modal-title'>Appointment Requested</h5>
                            <button type='button' class='close' data-dismiss='modal' aria-label='Close'>
                              <span aria-hidden='true'>&times;</span>
                            </button>
                          </div>
                          <div class='modal-body'>
                            <p>$success</p>
                          </div>
                          <div class='modal-footer'>
                            <button type='button' class='btn btn-gold' data-dismiss='modal'>Close</button>
                          </div>
                        </div>
                      </div>
                    </div>
                    ";
                }
                if (!empty($errors)) {
                    foreach ($errors as $error) {
                        echo "<div class='alert alert-danger'>$error</div>";
                    }
                }
                ?>
                <form method="POST" action="">
                    <div class="form-group">
                        <label for="package_id">Select Package</label>
                        <select name="package_id" id="package_id" class="form-control" onchange="showPackageDetails()" required>
                            <option value="">Select Package</option>
                            <?php
                            foreach ($packages as $pkg) {
                                // Retain selected value after submission
                                $selected = (isset($_POST['package_id']) && $_POST['package_id'] == $pkg['id']) ? 'selected' : '';
                                echo "<option value='" . htmlspecialchars($pkg['id'], ENT_QUOTES, 'UTF-8') . "' $selected>" . htmlspecialchars($pkg['package_name'], ENT_QUOTES, 'UTF-8') . "</option>";
                            }
                            ?>
                        </select>
                    </div>
                    <div id="package_details" class="package-details">
                        <h5>Package Details</h5>
                        <p id="package_description"></p>
                    </div>
                    <div class="form-group">
                        <label for="appointment_date">Preferred Appointment Date & Time</label>
                        <input type="datetime-local" name="appointment_date" class="form-control" 
                        value="<?php echo isset($_POST['appointment_date']) ? htmlspecialchars($_POST['appointment_date'], ENT_QUOTES, 'UTF-8') : ''; ?>" required/>
                    </div>
                    <div class="form-group">
                        <label for="additional_notes">Additional Notes</label>
                        <textarea name="additional_notes" class="form-control" rows="4" placeholder="Any additional information or special requests"><?php echo isset($_POST['additional_notes']) ? htmlspecialchars($_POST['additional_notes'], ENT_QUOTES, 'UTF-8') : ''; ?></textarea>
                    </div>
                    <button type="submit" class="btn btn-gold btn-block">Request Appointment</button>
                </form>
            </div>
        </div>

        <!-- Contact Info -->
        <div class="contact-info">
            <p><i class="fas fa-envelope"></i> Email: info@longevacare.com</p>
            <p><i class="fas fa-phone"></i> Phone: +971 528 863 600</p>
            <p><i class="fab fa-whatsapp"></i> WhatsApp: +1 (702) 526-2050</p>
            <p><i class="fas fa-map-marker-alt"></i> Location: HDS Tower, Cluster M, JLT, Dubai</p>
        </div>
    </div>

    <!-- Footer -->
    <div class="footer">
        &copy; <?php echo date('Y'); ?> LONGEVA. All rights reserved.
    </div>

    <!-- Include jQuery and Bootstrap JS -->
    <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>

    <script>
        function showPackageDetails() {
            var packageSelect = document.getElementById('package_id');
            var packageId = packageSelect.value;
            var packageDetailsDiv = document.getElementById('package_details');
            var packageDescriptionP = document.getElementById('package_description');

            if (packageId) {
                var packages = <?php echo json_encode($packages); ?>;
                var selectedPackage = packages.find(function(pkg) { return pkg.id == packageId; });
                if (selectedPackage) {
                    packageDescriptionP.innerText = selectedPackage.description;
                    packageDetailsDiv.style.display = 'block';
                } else {
                    packageDetailsDiv.style.display = 'none';
                    packageDescriptionP.innerText = '';
                }
            } else {
                packageDetailsDiv.style.display = 'none';
                packageDescriptionP.innerText = '';
            }
        }

        $(document).ready(function() {
            // Retain package details if a package was previously selected
            <?php if (!empty($_POST['package_id'])) { ?>
                showPackageDetails();
            <?php } ?>

            // Show the success modal if success message is set
            <?php if (!empty($success)) { ?>
                $('#successModal').modal('show');
            <?php } ?>
        });
    </script>
</body>
</html>
Key Features:

Patient Data Fetching: Retrieves patient information from the database using patient_id stored in the session.
Package Selection: Fetches available packages from the packages table and displays them in a dropdown.
Package Details Display: Shows the selected package's description dynamically without reloading the page.
Appointment Date & Time Selection: Users can select their preferred appointment slot.
Additional Notes: Optional field for any special requests.
Form Validation:
Ensures all required fields are filled.
Checks if the selected appointment slot is available (no overlaps).
Validates that the appointment date and time are in the future.
Database Insertion: Inserts appointment data into the appointments table, linking it to the correct patient_id.
Email Confirmation: Sends a beautifully designed confirmation email to the user upon successful appointment request using PHPMailer.
6.5. Final Page (pages/page10.php)
Purpose: Confirm completion and provide a button to return to the homepage.

Functionality:

Confirm questionnaire completion.
Offer navigation options (e.g., return to homepage).
Optionally, provide a link to schedule or view appointments.
File: pages/page10.php


<?php
// pages/page10.php

// Enable error reporting for debugging (remove in production)
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

// Start session and include database connection
session_start();
require '../db_connect.php';

// Redirect to landing page if patient_id is not set
if (!isset($_SESSION['patient_id'])) {
    header("Location: ../index.php");
    exit();
}

// Optionally, you can perform any final data processing here

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    // Optionally, redirect to another page or perform actions
    header("Location: ../thank_you.php");
    exit();
}

?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Congratulations, You’re One Step Closer</title>
    <link rel="stylesheet" href="../assets/css/styles.css">
</head>
<body>
    <div class="container">
        <div class="header">
            <img src="../assets/images/gold-logo.png" alt="Longeva Logo">
            <h2>Congratulations, You’re One Step Closer</h2>
        </div>

        <div class="section">
            <h3>Congratulations, You’re One Step Closer</h3>
            <p>We will contact you shortly to begin your personalized health journey with Longeva.</p>
            <p>You’ll receive a comprehensive evaluation based on your inputs. Our experts will craft a personalized health plan focused on your unique needs.</p>
            <form method="POST" action="">
                <button type="submit" class="btn btn-gold">Return to Homepage</button>
            </form>
        </div>
    </div>
</body>
</html>
Key Features:

Confirmation Message: Notifies the user that they have completed the questionnaire.
Navigation: Provides a button to return to the homepage for further actions.
7. Thank You Page (thank_you.php)
Purpose: Display a final thank you message after completing the questionnaire.

Functionality:

Express gratitude for completing the questionnaire.
Inform the user that their responses are being reviewed.
Provide navigation options.
File: thank_you.php


<?php
// thank_you.php

// Optionally, you can start a session if you want to display personalized messages
session_start();
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Thank You!</title>
    <link rel="stylesheet" href="assets/css/styles.css">
</head>
<body>
    <div class="container">
        <div class="header">
            <img src="assets/images/gold-logo.png" alt="Longeva Logo">
            <h2>Thank You!</h2>
        </div>

        <div class="section">
            <h3>Thank You for Completing the Questionnaire!</h3>
            <p>Thank you for completing the Longeva Health Journey questionnaire. Our team will review your responses and reach out to you soon with personalized insights and next steps.</p>
            <p>You’ll receive a comprehensive evaluation based on your inputs. Our experts will craft a personalized health plan focused on your unique needs.</p>
            <a href="index.php" class="back-link">Return to Homepage</a>
        </div>
    </div>
</body>
</html>
Key Features:

Gratitude Message: Thanks the user for their participation.
Next Steps Information: Informs the user about the upcoming review and contact from the team.
Navigation: Provides a link back to the homepage.
8. Final Notes and Best Practices
8.1. Security Considerations
Input Sanitization and Validation: Always sanitize and validate user inputs to prevent XSS and SQL injection attacks.
Prepared Statements: Use prepared statements with bound parameters (as demonstrated) to secure database queries.
Session Management: Ensure sessions are handled securely. Regenerate session IDs when necessary and destroy sessions after completion.
Error Reporting: Disable error reporting in a production environment to prevent leakage of sensitive information.
8.2. Design Enhancements
Consistent Branding: Use your brand colors, logos, and fonts consistently across all pages.
Responsive Design: Ensure the application is fully responsive and looks great on all devices.
User Experience (UX):
Clear Navigation: Users should easily understand the flow.
Feedback: Provide immediate feedback on form submissions.
Accessibility: Ensure the application is accessible to all users, including those using screen readers.
8.3. Additional Features to Consider
User Authentication: Allow patients to create accounts to track their health journey, appointments, and records.
Email Notifications: Confirm appointments via email and send reminders.
Admin Dashboard: Enable administrators to view and manage appointments, patient records, and other data.
Analytics: Track user interactions and appointment statistics for better insights.
Loaders and Progress Indicators: Enhance the user experience by showing progress throughout the questionnaire.
8.4. Testing
Cross-Browser Compatibility: Test the application on all major browsers (Chrome, Firefox, Safari, Edge).
Form Validation: Ensure all forms validate inputs correctly and handle errors gracefully.
Database Operations: Verify that all data is correctly inserted, updated, and retrieved from the database.
Responsive Design: Test on various devices and screen sizes.
8.5. Deployment
Secure Hosting: Host your application on a secure server with HTTPS enabled.
Database Backups: Regularly back up your database to prevent data loss.
Monitoring: Implement monitoring tools to track application performance and uptime.
Full Code Summary
pages/appointment.php
(As provided above)

Key Points to Ensure Functionality:
Session Handling: Ensure that during the questionnaire (page1.php to page6.php), the patient_id is set in the session after inserting a new patient record. Example:

// After successfully creating a patient during page1.php

if (!isset($_SESSION['patient_id'])) {
    $_SESSION['patient_id'] = $pdo->lastInsertId();
}
PHPMailer Configuration:
SMTP Settings: Replace the placeholder SMTP settings (Host, Username, Password) with your actual SMTP server details.
Secure Credentials: Never hard-code sensitive credentials directly into the code. Consider using environment variables or secure configuration files.
Composer Autoloading:
Ensure the vendor/autoload.php path is correct based on your project structure.
If using a different directory structure, adjust the require path accordingly.
Database Integrity:
Ensure all foreign key constraints are correctly set up to maintain data integrity.
Regularly back up your database to prevent data loss.
Testing:
Form Submission: Test the appointment form by submitting valid and invalid data to ensure validations work.
Email Sending: Verify that confirmation emails are sent correctly upon successful appointment requests.
Database Entries: Check the appointments table to confirm that appointment data is being stored as expected.
Error Handling:
Provide user-friendly error messages.
Log detailed errors on the server-side for debugging purposes without exposing them to the user.
Implementing the Changes: Step-by-Step Guide
Update the Database:
Add patient_id to the appointments table using the provided SQL statements.
Verify that the packages table contains relevant packages.
Install PHPMailer via Composer:
Navigate to your project root in the terminal.
Run: composer require phpmailer/phpmailer
Ensure the vendor/ directory is created with PHPMailer installed.
Configure db_connect.php:
Ensure your database credentials are correct.
Use PDO for database interactions as shown.
Enhance the Stylesheet:
Replace your existing styles.css with the provided enhanced stylesheet.
Adjust any custom styles if necessary.
Update Questionnaire Pages:
Page 7 (page7.php): Calculates and displays BMI based on user input.
Page 8 (page8.php): Provides detailed analysis and options to schedule an appointment or return home.
Appointment Page (appointment.php): Allows users to schedule their appointments, sends confirmation emails, and stores data in the database.
Final Page (page10.php): Confirms questionnaire completion and offers navigation options.
Test the Application:
Navigate through the questionnaire pages (page1.php to page6.php).
Ensure data is saved correctly and patient_id is set in the session.
Proceed to page7.php to view BMI analysis.
Continue to page8.php and choose to schedule an appointment.
Complete appointment.php and verify that:
Appointment data is stored in the appointments table.
A confirmation email is sent to the user.
Conclude with page10.php and navigate to the thank you page.
Finalize Design and Deployment:
Ensure all pages have a consistent and modern design.
Deploy the application to a secure server with HTTPS.
Monitor application performance and address any issues promptly.
Conclusion
By following this comprehensive guide, you've successfully enhanced your Longeva Health Journey application to provide users with personalized health analysis and a streamlined appointment scheduling system. The integration of PHPMailer ensures that users receive timely confirmation emails, enhancing their overall experience.

Next Steps:

Implement the provided codes and test thoroughly.
Gather user feedback to make further improvements.
Consider adding additional features like user authentication, admin dashboards, and more detailed health analytics based on your requirements.
Feel free to reach out if you encounter any issues or need further assistance!

) i want to remove appointoment page and vendor too and i have link any thing related to appointoment but i have link about appointment i want user go to (https://info.longevacare.com/appointment/public_appointment.php) after fill the form and type full codes with guides and this info databse (-- phpMyAdmin SQL Dump
-- version 5.2.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1:3306
-- Generation Time: Oct 15, 2024 at 02:17 PM
-- Server version: 10.11.9-MariaDB
-- PHP Version: 7.2.34

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- Database: `u406552082_info`
--

-- --------------------------------------------------------

--
-- Table structure for table `admins`
--

CREATE TABLE `admins` (
  `id` int(11) NOT NULL,
  `username` varchar(50) NOT NULL,
  `password` varchar(255) NOT NULL,
  `email` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `appointments`
--

CREATE TABLE `appointments` (
  `id` int(11) NOT NULL,
  `package_id` int(11) NOT NULL,
  `appointment_date` datetime NOT NULL,
  `proposed_appointment_date` datetime DEFAULT NULL,
  `name` varchar(255) NOT NULL,
  `email` varchar(255) NOT NULL,
  `phone` varchar(20) NOT NULL,
  `age` int(3) DEFAULT NULL,
  `gender` enum('Male','Female','Other') DEFAULT NULL,
  `address` varchar(255) DEFAULT NULL,
  `preferred_contact_method` enum('Email','Phone','WhatsApp') DEFAULT NULL,
  `additional_notes` text DEFAULT NULL,
  `status` enum('Pending','Confirmed','Completed','Cancelled') DEFAULT 'Pending',
  `created_at` timestamp NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `budgets`
--

CREATE TABLE `budgets` (
  `id` int(11) NOT NULL,
  `month` varchar(7) DEFAULT NULL,
  `budgeted_revenue` decimal(10,2) DEFAULT NULL,
  `budgeted_expenses` decimal(10,2) DEFAULT NULL,
  `notes` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `comments`
--

CREATE TABLE `comments` (
  `id` int(11) NOT NULL,
  `patient_id` int(11) NOT NULL,
  `sender` enum('patient','doctor','admin') NOT NULL,
  `message` text NOT NULL,
  `timestamp` datetime DEFAULT current_timestamp(),
  `parent_id` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `doctors`
--

CREATE TABLE `doctors` (
  `id` int(11) NOT NULL,
  `employee_id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `username` varchar(100) NOT NULL,
  `password` varchar(255) NOT NULL,
  `email` varchar(255) NOT NULL,
  `specialization` varchar(255) DEFAULT NULL,
  `phone` varchar(20) DEFAULT NULL,
  `registration_date` date DEFAULT curdate(),
  `profile_picture` varchar(255) DEFAULT NULL,
  `department` varchar(100) DEFAULT NULL,
  `date_of_joining` date DEFAULT NULL,
  `status` enum('active','inactive') DEFAULT 'active'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `doctor_patient`
--

CREATE TABLE `doctor_patient` (
  `id` int(11) NOT NULL,
  `doctor_id` int(11) NOT NULL,
  `patient_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `employees`
--

CREATE TABLE `employees` (
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `role` enum('admin','doctor','staff','accountant') NOT NULL,
  `email` varchar(255) NOT NULL,
  `phone` varchar(20) DEFAULT NULL,
  `department` varchar(100) DEFAULT NULL,
  `date_of_joining` date DEFAULT NULL,
  `status` enum('active','inactive') DEFAULT 'active',
  `username` varchar(100) NOT NULL,
  `password` varchar(255) NOT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `profile_picture` varchar(255) DEFAULT NULL,
  `specialization` varchar(255) DEFAULT NULL,
  `is_online` tinyint(1) DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `expenses`
--

CREATE TABLE `expenses` (
  `id` int(11) NOT NULL,
  `expense_date` date NOT NULL,
  `category` varchar(100) NOT NULL,
  `description` varchar(255) DEFAULT NULL,
  `amount` decimal(10,2) NOT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `health_records`
--

CREATE TABLE `health_records` (
  `id` int(11) NOT NULL,
  `patient_id` int(11) NOT NULL,
  `blood_pressure` varchar(20) DEFAULT NULL,
  `weight` decimal(5,2) DEFAULT NULL,
  `bmi` decimal(4,2) DEFAULT NULL,
  `cholesterol` decimal(5,2) DEFAULT NULL,
  `prescription` text DEFAULT NULL,
  `treatment_progress` text DEFAULT NULL,
  `record_date` date NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `insurance_claims`
--

CREATE TABLE `insurance_claims` (
  `id` int(11) NOT NULL,
  `patient_id` int(11) DEFAULT NULL,
  `invoice_id` int(11) DEFAULT NULL,
  `claim_amount` decimal(10,2) DEFAULT NULL,
  `status` enum('Pending','Approved','Rejected') DEFAULT NULL,
  `submission_date` date DEFAULT NULL,
  `processing_date` date DEFAULT NULL,
  `notes` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `invoices`
--

CREATE TABLE `invoices` (
  `id` int(11) NOT NULL,
  `patient_id` int(11) NOT NULL,
  `service_name` varchar(255) NOT NULL,
  `service_description` text DEFAULT NULL,
  `cost` decimal(10,2) NOT NULL,
  `tax_rate` decimal(5,2) DEFAULT 0.00,
  `discount` decimal(5,2) DEFAULT 0.00,
  `total_amount` decimal(10,2) NOT NULL,
  `invoice_date` date DEFAULT curdate(),
  `due_date` date DEFAULT NULL,
  `notes` text DEFAULT NULL,
  `tax` decimal(5,2) DEFAULT 0.00
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `invoice_services`
--

CREATE TABLE `invoice_services` (
  `id` int(11) NOT NULL,
  `invoice_id` int(11) NOT NULL,
  `service_id` int(11) NOT NULL,
  `service_name` varchar(255) NOT NULL,
  `cost` decimal(10,2) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `packages`
--

CREATE TABLE `packages` (
  `id` int(11) NOT NULL,
  `package_name` varchar(255) NOT NULL,
  `description` text DEFAULT NULL,
  `details` text DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `patients`
--

CREATE TABLE `patients` (
  `id` int(11) NOT NULL,
  `name` varchar(100) NOT NULL,
  `age` int(11) NOT NULL,
  `gender` enum('Male','Female','Other') NOT NULL,
  `phone` varchar(20) DEFAULT NULL,
  `email` varchar(100) DEFAULT NULL,
  `medical_history` text DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `date_of_birth` date DEFAULT NULL,
  `registration_datetime` datetime DEFAULT current_timestamp(),
  `registration_date` date DEFAULT NULL,
  `status` enum('Initial Consultation','Diagnostic Phase','Treatment in Progress','Improving','Monitoring','Maintenance Phase','Awaiting Test Results','Follow-up Needed','Paused','Completed Program','Relapsed','Discontinued','Inactive') DEFAULT 'Initial Consultation',
  `doctor_id` int(11) DEFAULT NULL,
  `address` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `patient_logins`
--

CREATE TABLE `patient_logins` (
  `id` int(11) NOT NULL,
  `patient_id` int(11) NOT NULL,
  `username` varchar(50) NOT NULL,
  `password` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `payments`
--

CREATE TABLE `payments` (
  `id` int(11) NOT NULL,
  `patient_id` int(11) NOT NULL,
  `invoice_id` int(11) NOT NULL,
  `amount_paid` decimal(10,2) NOT NULL,
  `payment_date` date NOT NULL,
  `payment_method` varchar(50) DEFAULT NULL,
  `notes` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `prescriptions`
--

CREATE TABLE `prescriptions` (
  `id` int(11) NOT NULL,
  `patient_id` int(11) NOT NULL,
  `doctor_id` int(11) DEFAULT NULL,
  `medications` text NOT NULL,
  `instructions` text DEFAULT NULL,
  `date_prescribed` datetime DEFAULT current_timestamp(),
  `status` enum('active','inactive') DEFAULT 'active'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `salaries`
--

CREATE TABLE `salaries` (
  `id` int(11) NOT NULL,
  `employee_id` int(11) NOT NULL,
  `basic_salary` decimal(10,2) NOT NULL,
  `bonuses` decimal(10,2) DEFAULT 0.00,
  `deductions` decimal(10,2) DEFAULT 0.00,
  `overtime_hours` int(11) DEFAULT 0,
  `overtime_rate` decimal(10,2) DEFAULT 0.00,
  `tax` decimal(10,2) DEFAULT 0.00,
  `payment_date` date NOT NULL,
  `net_salary` decimal(10,2) NOT NULL,
  `status` enum('Pending','Paid') DEFAULT 'Pending',
  `notes` text DEFAULT NULL,
  `payslip_path` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `services`
--

CREATE TABLE `services` (
  `service_id` int(11) NOT NULL,
  `service_name` varchar(255) NOT NULL,
  `service_price` decimal(10,2) NOT NULL,
  `service_description` text DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `admins`
--
ALTER TABLE `admins`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `username` (`username`);

--
-- Indexes for table `appointments`
--
ALTER TABLE `appointments`
  ADD PRIMARY KEY (`id`),
  ADD KEY `package_id` (`package_id`);

--
-- Indexes for table `budgets`
--
ALTER TABLE `budgets`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `comments`
--
ALTER TABLE `comments`
  ADD PRIMARY KEY (`id`),
  ADD KEY `patient_id` (`patient_id`);

--
-- Indexes for table `doctors`
--
ALTER TABLE `doctors`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `username` (`username`),
  ADD UNIQUE KEY `email` (`email`),
  ADD KEY `employee_id` (`employee_id`);

--
-- Indexes for table `doctor_patient`
--
ALTER TABLE `doctor_patient`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `doctor_id` (`doctor_id`,`patient_id`),
  ADD KEY `fk_doctor_patient_patient_id` (`patient_id`);

--
-- Indexes for table `employees`
--
ALTER TABLE `employees`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `email` (`email`),
  ADD UNIQUE KEY `username` (`username`);

--
-- Indexes for table `expenses`
--
ALTER TABLE `expenses`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `health_records`
--
ALTER TABLE `health_records`
  ADD PRIMARY KEY (`id`),
  ADD KEY `patient_id` (`patient_id`);

--
-- Indexes for table `insurance_claims`
--
ALTER TABLE `insurance_claims`
  ADD PRIMARY KEY (`id`),
  ADD KEY `patient_id` (`patient_id`),
  ADD KEY `invoice_id` (`invoice_id`);

--
-- Indexes for table `invoices`
--
ALTER TABLE `invoices`
  ADD PRIMARY KEY (`id`),
  ADD KEY `patient_id` (`patient_id`);

--
-- Indexes for table `invoice_services`
--
ALTER TABLE `invoice_services`
  ADD PRIMARY KEY (`id`),
  ADD KEY `invoice_id` (`invoice_id`),
  ADD KEY `service_id` (`service_id`);

--
-- Indexes for table `packages`
--
ALTER TABLE `packages`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `patients`
--
ALTER TABLE `patients`
  ADD PRIMARY KEY (`id`),
  ADD KEY `doctor_id` (`doctor_id`);

--
-- Indexes for table `patient_logins`
--
ALTER TABLE `patient_logins`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `patient_id` (`patient_id`),
  ADD UNIQUE KEY `username` (`username`);

--
-- Indexes for table `payments`
--
ALTER TABLE `payments`
  ADD PRIMARY KEY (`id`),
  ADD KEY `patient_id` (`patient_id`),
  ADD KEY `invoice_id` (`invoice_id`);

--
-- Indexes for table `prescriptions`
--
ALTER TABLE `prescriptions`
  ADD PRIMARY KEY (`id`),
  ADD KEY `patient_id` (`patient_id`),
  ADD KEY `doctor_id` (`doctor_id`);

--
-- Indexes for table `salaries`
--
ALTER TABLE `salaries`
  ADD PRIMARY KEY (`id`),
  ADD KEY `employee_id` (`employee_id`);

--
-- Indexes for table `services`
--
ALTER TABLE `services`
  ADD PRIMARY KEY (`service_id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `admins`
--
ALTER TABLE `admins`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `appointments`
--
ALTER TABLE `appointments`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `budgets`
--
ALTER TABLE `budgets`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `comments`
--
ALTER TABLE `comments`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `doctors`
--
ALTER TABLE `doctors`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `doctor_patient`
--
ALTER TABLE `doctor_patient`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `employees`
--
ALTER TABLE `employees`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `expenses`
--
ALTER TABLE `expenses`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `health_records`
--
ALTER TABLE `health_records`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `insurance_claims`
--
ALTER TABLE `insurance_claims`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `invoices`
--
ALTER TABLE `invoices`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `invoice_services`
--
ALTER TABLE `invoice_services`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `packages`
--
ALTER TABLE `packages`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `patients`
--
ALTER TABLE `patients`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `patient_logins`
--
ALTER TABLE `patient_logins`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `payments`
--
ALTER TABLE `payments`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `prescriptions`
--
ALTER TABLE `prescriptions`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `salaries`
--
ALTER TABLE `salaries`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `services`
--
ALTER TABLE `services`
  MODIFY `service_id` int(11) NOT NULL AUTO_INCREMENT;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `appointments`
--
ALTER TABLE `appointments`
  ADD CONSTRAINT `appointments_ibfk_1` FOREIGN KEY (`package_id`) REFERENCES `packages` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `comments`
--
ALTER TABLE `comments`
  ADD CONSTRAINT `comments_ibfk_1` FOREIGN KEY (`patient_id`) REFERENCES `patients` (`id`);

--
-- Constraints for table `doctors`
--
ALTER TABLE `doctors`
  ADD CONSTRAINT `doctors_ibfk_1` FOREIGN KEY (`employee_id`) REFERENCES `employees` (`id`);

--
-- Constraints for table `doctor_patient`
--
ALTER TABLE `doctor_patient`
  ADD CONSTRAINT `doctor_patient_fk_doctor_id` FOREIGN KEY (`doctor_id`) REFERENCES `doctors` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `doctor_patient_ibfk_2` FOREIGN KEY (`patient_id`) REFERENCES `patients` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_doctor` FOREIGN KEY (`doctor_id`) REFERENCES `doctors` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_doctor_patient_doctor_id` FOREIGN KEY (`doctor_id`) REFERENCES `doctors` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_doctor_patient_patient_id` FOREIGN KEY (`patient_id`) REFERENCES `patients` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `health_records`
--
ALTER TABLE `health_records`
  ADD CONSTRAINT `health_records_ibfk_1` FOREIGN KEY (`patient_id`) REFERENCES `patients` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `insurance_claims`
--
ALTER TABLE `insurance_claims`
  ADD CONSTRAINT `insurance_claims_ibfk_1` FOREIGN KEY (`patient_id`) REFERENCES `patients` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `insurance_claims_ibfk_2` FOREIGN KEY (`invoice_id`) REFERENCES `invoices` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `invoices`
--
ALTER TABLE `invoices`
  ADD CONSTRAINT `invoices_ibfk_1` FOREIGN KEY (`patient_id`) REFERENCES `patients` (`id`);

--
-- Constraints for table `invoice_services`
--
ALTER TABLE `invoice_services`
  ADD CONSTRAINT `invoice_services_ibfk_1` FOREIGN KEY (`invoice_id`) REFERENCES `invoices` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `invoice_services_ibfk_2` FOREIGN KEY (`service_id`) REFERENCES `services` (`service_id`) ON DELETE CASCADE;

--
-- Constraints for table `patients`
--
ALTER TABLE `patients`
  ADD CONSTRAINT `patients_ibfk_1` FOREIGN KEY (`doctor_id`) REFERENCES `doctors` (`id`) ON DELETE SET NULL ON UPDATE CASCADE;

--
-- Constraints for table `patient_logins`
--
ALTER TABLE `patient_logins`
  ADD CONSTRAINT `patient_logins_ibfk_1` FOREIGN KEY (`patient_id`) REFERENCES `patients` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `payments`
--
ALTER TABLE `payments`
  ADD CONSTRAINT `payments_ibfk_1` FOREIGN KEY (`patient_id`) REFERENCES `patients` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `payments_ibfk_2` FOREIGN KEY (`invoice_id`) REFERENCES `invoices` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `prescriptions`
--
ALTER TABLE `prescriptions`
  ADD CONSTRAINT `prescriptions_ibfk_1` FOREIGN KEY (`patient_id`) REFERENCES `patients` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `prescriptions_ibfk_2` FOREIGN KEY (`doctor_id`) REFERENCES `doctors` (`id`) ON DELETE SET NULL;

--
-- Constraints for table `salaries`
--
ALTER TABLE `salaries`
  ADD CONSTRAINT `salaries_ibfk_1` FOREIGN KEY (`employee_id`) REFERENCES `employees` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;) and make add more features in codes make it cool deisgn and type full guides