i want to update this info (Table of Contents
Project Structure
Database Setup
Configuration File (db_connect.php)
Stylesheet (assets/css/styles.css)
Questionnaire Pages
5.1. Landing Page (index.php)
5.2. Page 1: Introduction and Start (pages/page1.php)
5.3. Page 2: Privacy and Consent (pages/page2.php)
5.4. Page 3: Basic Information (pages/page3.php)
5.5. Page 4: Health Metrics & Lifestyle (pages/page4.php)
5.6. Page 5: Medical History (pages/page5.php)
5.7. Page 6: Your Goals (pages/page6.php)
5.8. Page 7: The Longeva Approach (pages/page7.php)
5.9. Page 8: Longeva Programs Overview (pages/page8.php)
5.10. Page 9: Personalized Consultation (pages/page9.php)
5.11. Page 10: Final Page (pages/page10.php)
Thank You Page (thank_you.php)
Additional Enhancements and Best Practices
Testing the Application
Final Notes
1. Project Structure
Ensure your project directory is organized as follows:


longeva_health_journey/
│
├── assets/
│   ├── css/
│   │   └── styles.css
│   └── images/
│       └── gold-logo.png
│       └── questionnaire_icon.png  # Add your questionnaire icon here
│
├── db_connect.php
├── index.php
├── thank_you.php
│
└── pages/
    ├── page1.php
    ├── page2.php
    ├── page3.php
    ├── page4.php
    ├── page5.php
    ├── page6.php
    ├── page7.php
    ├── page8.php
    ├── page9.php
    └── page10.php
Explanation:

assets/: Contains static resources like CSS and images.
css/: Holds the styles.css file for styling.
images/: Contains images such as gold-logo.png and questionnaire_icon.png.
db_connect.php: Handles database connections using PDO.
index.php: The landing page that redirects to page1.php.
thank_you.php: Final page displayed after completing the questionnaire.
pages/: Contains individual PHP files for each questionnaire page (page1.php to page10.php).
2. Database Setup
2.1. Import Existing Database
Use phpMyAdmin or any MySQL client to import your existing database dump (u406552082_info). Ensure all existing tables are correctly imported.

2.2. Create New Tables for Questionnaire Responses
Instead of updating the patients table, we'll create new tables to store responses from each questionnaire page. These tables will reference the patients table via foreign keys.

Run the following SQL statements in your MySQL client or phpMyAdmin to create the necessary tables:


-- Table: patient_consent
CREATE TABLE `patient_consent` (
    `patient_id` INT(11) NOT NULL,
    `consent` ENUM('accepted', 'declined') NOT NULL,
    PRIMARY KEY (`patient_id`),
    FOREIGN KEY (`patient_id`) REFERENCES `patients`(`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Table: patient_basic_info
CREATE TABLE `patient_basic_info` (
    `patient_id` INT(11) NOT NULL,
    `gender` ENUM('Male', 'Female', 'Other') NULL,
    `age` INT(3) NULL,
    `weight` DECIMAL(5,2) NULL,
    `height` DECIMAL(5,2) NULL,
    PRIMARY KEY (`patient_id`),
    FOREIGN KEY (`patient_id`) REFERENCES `patients`(`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Table: patient_health_metrics
CREATE TABLE `patient_health_metrics` (
    `patient_id` INT(11) NOT NULL,
    `exercise_frequency` ENUM('Daily', 'Weekly', 'Rarely', 'Never') NOT NULL,
    `diet` ENUM('Yes', 'No') NOT NULL,
    `diet_specify` VARCHAR(255) DEFAULT NULL,
    `sleep_average` ENUM('<5 Hours', '5-7 Hours', '7-9 Hours', '>9 Hours') NOT NULL,
    `smoking_status` ENUM('Yes', 'No', 'Occasionally') NOT NULL,
    PRIMARY KEY (`patient_id`),
    FOREIGN KEY (`patient_id`) REFERENCES `patients`(`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Table: patient_medical_history
CREATE TABLE `patient_medical_history` (
    `patient_id` INT(11) NOT NULL,
    `chronic_conditions` ENUM('Yes', 'No') NOT NULL,
    `chronic_conditions_specify` VARCHAR(255) DEFAULT NULL,
    `medications` ENUM('Yes', 'No') NOT NULL,
    `medications_list` TEXT DEFAULT NULL,
    `major_surgeries` ENUM('Yes', 'No') NOT NULL,
    `major_surgeries_specify` VARCHAR(255) DEFAULT NULL,
    PRIMARY KEY (`patient_id`),
    FOREIGN KEY (`patient_id`) REFERENCES `patients`(`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Table: patient_goals
CREATE TABLE `patient_goals` (
    `patient_id` INT(11) NOT NULL,
    `primary_health_goals` TEXT NOT NULL,
    `health_concerns` TEXT NOT NULL,
    PRIMARY KEY (`patient_id`),
    FOREIGN KEY (`patient_id`) REFERENCES `patients`(`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Table: patient_consultation
CREATE TABLE `patient_consultation` (
    `patient_id` INT(11) NOT NULL,
    `scheduled_at` DATETIME NOT NULL,
    PRIMARY KEY (`patient_id`),
    FOREIGN KEY (`patient_id`) REFERENCES `patients`(`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
Explanation of Tables:

patient_consent
Stores the patient's consent status.
patient_basic_info
Stores basic demographic information.
patient_health_metrics
Stores health-related metrics and lifestyle habits.
patient_medical_history
Stores medical history details.
patient_goals
Stores the patient's health goals and concerns.
patient_consultation
Stores the scheduled consultation datetime.
Note: Ensure that the patients table has the necessary columns (id, name, age, gender, email, registration_datetime, etc.) and that the id column is set to AUTO_INCREMENT.

3. Configuration File (db_connect.php)
Create a db_connect.php file in the root directory to handle database connections using PDO.


<?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.

4. Stylesheet (assets/css/styles.css)
Create a styles.css file inside the assets/css/ directory with the following content to style the questionnaire:


/* 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;
}

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: 700px;
    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"] {
    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 {
    background-color: var(--button-hover-color);
}

.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;
}

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

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

.success {
    background-color: #d4edda;
    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;
    }
}
Explanation:

Modern Typography: Uses the 'Roboto' font for a clean and professional look.
Color Scheme: Utilizes a combination of primary and secondary colors with a subtle background.
Responsive Design: Adjusts layout and font sizes for smaller screens.
Interactive Elements: Hover effects on sections and buttons enhance user experience.
Error and Success Messages: Styled to provide clear feedback to users.
5. Questionnaire Pages
Each questionnaire page is designed to be self-contained without relying on separate header and footer files. Each page starts a session, connects to the database, displays the form, handles form submissions, and stores data logically associated with the patient.

5.1. Landing Page (index.php)
Purpose: Redirect users to the first questionnaire page.


<?php
// index.php
header("Location: pages/page1.php");
exit();
?>
5.2. Page 1: Introduction and Start (pages/page1.php)
Purpose: Welcome the user and provide a button to start the evaluation.


<?php
// pages/page1.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';

$errors = [];

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    try {
        // Initialize patient record if not already done
        if (!isset($_SESSION['patient_id'])) {
            // Insert a new patient with minimal data
            $stmt = $pdo->prepare("
                INSERT INTO patients (name, age, gender, email, registration_datetime) 
                VALUES (:name, :age, :gender, :email, NOW())
            ");
            $stmt->execute([
                ':name' => '',
                ':age' => NULL,
                ':gender' => NULL,
                ':email' => ''
            ]);
            $_SESSION['patient_id'] = $pdo->lastInsertId();
        }
        header("Location: page2.php");
        exit();
    } catch (PDOException $e) {
        $errors[] = "Database Error: " . $e->getMessage();
    }
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Begin Your Journey to a Longer Healthier Life</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>Begin your journey to a longer healthier life</h2>
        </div>

        <div class="section">
            <h3>Welcome to Longeva Health Journey</h3>
            <p>Take our short, proprietary health survey for free.</p>
            <p>It will only take 10 minutes, and you will receive an initial assessment with key insights on how you can make simple adjustments to begin improving and optimizing your health.</p>
            <img src="../assets/images/questionnaire_icon.png" alt="Questionnaire Icon" style="width: 100px; height: 100px; display: block; margin: 20px auto;">
            
            <?php
            if (!empty($errors)) {
                echo '<div class="error">';
                foreach($errors as $error){
                    echo "<p>$error</p>";
                }
                echo '</div>';
            }
            ?>

            <form method="POST" action="">
                <input type="submit" value="Start Online Evaluation Now">
            </form>
        </div>
    </div>
</body>
</html>
Key Features:

Introduction Text: Clearly communicates the purpose and benefits of the questionnaire.
Icon: Adds a visual element (questionnaire_icon.png) to make the page more engaging.
Start Button: Initiates the questionnaire by redirecting to page2.php.
Note: Ensure that you have a suitable questionnaire_icon.png in the assets/images/ directory.

5.3. Page 2: Privacy and Consent (pages/page2.php)
Purpose: Obtain the user's consent to process their data.


<?php
// pages/page2.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';

$errors = [];

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if (isset($_POST['consent']) && $_POST['consent'] === 'accepted') {
        try {
            if (isset($_SESSION['patient_id'])) {
                // Check if consent already exists
                $stmt = $pdo->prepare("SELECT patient_id FROM patient_consent WHERE patient_id = ?");
                $stmt->execute([$_SESSION['patient_id']]);
                if ($stmt->rowCount() > 0) {
                    // Update existing consent
                    $stmt = $pdo->prepare("UPDATE patient_consent SET consent = ? WHERE patient_id = ?");
                    $stmt->execute(['accepted', $_SESSION['patient_id']]);
                } else {
                    // Insert new consent
                    $stmt = $pdo->prepare("INSERT INTO patient_consent (patient_id, consent) VALUES (?, ?)");
                    $stmt->execute([$_SESSION['patient_id'], 'accepted']);
                }
                header("Location: page3.php");
                exit();
            } else {
                $errors[] = "Session expired. Please start over.";
            }
        } catch (PDOException $e) {
            $errors[] = "Database Error: " . $e->getMessage();
        }
    } else {
        $errors[] = "You must accept the Privacy Policy to continue.";
    }
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Privacy and Consent</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>Longevity Center – Your Health, Our Priority</h2>
        </div>

        <div class="section">
            <h3>Privacy and Consent</h3>
            <p>To provide you with personalized health insights, we need to process your data. Please read our <a href="#">Privacy Policy</a> for more information.</p>

            <?php
            if (!empty($errors)) {
                echo '<div class="error">';
                foreach($errors as $error){
                    echo "<p>$error</p>";
                }
                echo '</div>';
            }
            ?>

            <form method="POST" action="">
                <div class="form-group">
                    <input type="checkbox" id="consent" name="consent" value="accepted">
                    <label for="consent">I accept the Privacy Policy</label>
                </div>
                <input type="submit" value="Continue">
            </form>
        </div>
    </div>
</body>
</html>
Key Features:

Consent Checkbox: Users must accept the Privacy Policy to proceed.
Error Handling: Displays an error message if the user does not accept the Privacy Policy or if there's a session/database error.
5.4. Page 3: Basic Information (pages/page3.php)
Purpose: Collect basic demographic information.


<?php
// pages/page3.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 = [];

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    // Sanitize and validate inputs
    $gender = isset($_POST['gender']) ? htmlspecialchars(trim($_POST['gender'])) : '';
    $age = isset($_POST['age']) ? intval($_POST['age']) : '';
    $weight = isset($_POST['weight']) ? floatval($_POST['weight']) : '';
    $height = isset($_POST['height']) ? floatval($_POST['height']) : '';

    // Basic validation
    if (empty($gender)) {
        $errors[] = "Gender is required.";
    }
    if (empty($age) || $age <= 0) {
        $errors[] = "Valid age is required.";
    }
    if (empty($weight) || $weight <= 0) {
        $errors[] = "Valid weight is required.";
    }
    if (empty($height) || $height <= 0) {
        $errors[] = "Valid height is required.";
    }

    if (empty($errors)) {
        try {
            // Check if basic_info already exists
            $stmt = $pdo->prepare("SELECT patient_id FROM patient_basic_info WHERE patient_id = ?");
            $stmt->execute([$_SESSION['patient_id']]);
            if ($stmt->rowCount() > 0) {
                // Update existing record
                $stmt = $pdo->prepare("UPDATE patient_basic_info SET gender = ?, age = ?, weight = ?, height = ? WHERE patient_id = ?");
                $stmt->execute([$gender, $age, $weight, $height, $_SESSION['patient_id']]);
            } else {
                // Insert new record
                $stmt = $pdo->prepare("INSERT INTO patient_basic_info (patient_id, gender, age, weight, height) VALUES (?, ?, ?, ?, ?)");
                $stmt->execute([$_SESSION['patient_id'], $gender, $age, $weight, $height]);
            }
            header("Location: page4.php");
            exit();
        } catch (PDOException $e) {
            $errors[] = "Database Error: " . $e->getMessage();
        }
    }
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Tell Us About 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>Tell Us About You</h2>
        </div>

        <div class="section">
            <h3>Tell Us About You</h3>
            <p>This helps us personalize your experience.</p>

            <?php
            if (!empty($errors)) {
                echo '<div class="error">';
                foreach($errors as $error){
                    echo "<p>$error</p>";
                }
                echo '</div>';
            }
            ?>

            <form method="POST" action="">
                <div class="form-group">
                    <label for="gender">Gender:</label>
                    <select id="gender" name="gender" required>
                        <option value="">--Select Gender--</option>
                        <option value="Male" <?php if(isset($gender) && $gender == 'Male') echo 'selected'; ?>>Male</option>
                        <option value="Female" <?php if(isset($gender) && $gender == 'Female') echo 'selected'; ?>>Female</option>
                        <option value="Other" <?php if(isset($gender) && $gender == 'Other') echo 'selected'; ?>>Other</option>
                    </select>
                </div>

                <div class="form-group">
                    <label for="age">Age:</label>
                    <input type="number" id="age" name="age" min="0" value="<?php echo isset($age) ? htmlspecialchars($age) : ''; ?>" required>
                </div>

                <div class="form-group">
                    <label for="weight">Weight (kg):</label>
                    <input type="number" step="0.1" id="weight" name="weight" min="0" value="<?php echo isset($weight) ? htmlspecialchars($weight) : ''; ?>" required>
                </div>

                <div class="form-group">
                    <label for="height">Height (cm):</label>
                    <input type="number" step="0.1" id="height" name="height" min="0" value="<?php echo isset($height) ? htmlspecialchars($height) : ''; ?>" required>
                </div>

                <input type="submit" value="Continue">
            </form>
        </div>
    </div>
</body>
</html>
Key Features:

Form Fields: Collects gender, age, weight, and height.
Data Association: Data is stored in the patient_basic_info table, linked via patient_id from the session.
Error Handling: Displays errors if validation fails or if there's a database error.
5.5. Page 4: Health Metrics & Lifestyle (pages/page4.php)
Purpose: Collect information about health metrics and lifestyle habits.


<?php
// pages/page4.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 = [];

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    // Sanitize and validate inputs
    $exercise = isset($_POST['exercise']) ? htmlspecialchars(trim($_POST['exercise'])) : '';
    $diet = isset($_POST['diet']) ? htmlspecialchars(trim($_POST['diet'])) : '';
    $diet_specify = isset($_POST['diet_specify']) ? htmlspecialchars(trim($_POST['diet_specify'])) : '';
    $sleep = isset($_POST['sleep']) ? htmlspecialchars(trim($_POST['sleep'])) : '';
    $smoking = isset($_POST['smoking']) ? htmlspecialchars(trim($_POST['smoking'])) : '';

    // Validate inputs
    if (empty($exercise)) {
        $errors[] = "Please specify how often you exercise.";
    }
    if (empty($diet)) {
        $errors[] = "Please specify if you follow any specific diet.";
    }
    if ($diet === 'Yes' && empty($diet_specify)) {
        $errors[] = "Please specify your diet.";
    }
    if (empty($sleep)) {
        $errors[] = "Please specify your average sleep.";
    }
    if (empty($smoking)) {
        $errors[] = "Please specify your smoking status.";
    }

    if (empty($errors)) {
        try {
            // Check if health_metrics already exists
            $stmt = $pdo->prepare("SELECT patient_id FROM patient_health_metrics WHERE patient_id = ?");
            $stmt->execute([$_SESSION['patient_id']]);
            if ($stmt->rowCount() > 0) {
                // Update existing record
                $stmt = $pdo->prepare("UPDATE patient_health_metrics SET exercise_frequency = ?, diet = ?, diet_specify = ?, sleep_average = ?, smoking_status = ? WHERE patient_id = ?");
                $stmt->execute([$exercise, $diet, $diet_specify, $sleep, $smoking, $_SESSION['patient_id']]);
            } else {
                // Insert new record
                $stmt = $pdo->prepare("INSERT INTO patient_health_metrics (patient_id, exercise_frequency, diet, diet_specify, sleep_average, smoking_status) VALUES (?, ?, ?, ?, ?, ?)");
                $stmt->execute([$_SESSION['patient_id'], $exercise, $diet, $diet_specify, $sleep, $smoking]);
            }
            header("Location: page5.php");
            exit();
        } catch (PDOException $e) {
            $errors[] = "Database Error: " . $e->getMessage();
        }
    }
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Understanding Your Health</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>Understanding Your Health</h2>
        </div>

        <div class="section">
            <h3>Understanding Your Health</h3>
            <p>Help us gain insights into your daily habits.</p>

            <?php
            if (!empty($errors)) {
                echo '<div class="error">';
                foreach($errors as $error){
                    echo "<p>$error</p>";
                }
                echo '</div>';
            }
            ?>

            <form method="POST" action="">
                <div class="form-group">
                    <label for="exercise">How often do you exercise?</label>
                    <select id="exercise" name="exercise" required>
                        <option value="">--Select Frequency--</option>
                        <option value="Daily" <?php if(isset($exercise) && $exercise == 'Daily') echo 'selected'; ?>>Daily</option>
                        <option value="Weekly" <?php if(isset($exercise) && $exercise == 'Weekly') echo 'selected'; ?>>Weekly</option>
                        <option value="Rarely" <?php if(isset($exercise) && $exercise == 'Rarely') echo 'selected'; ?>>Rarely</option>
                        <option value="Never" <?php if(isset($exercise) && $exercise == 'Never') echo 'selected'; ?>>Never</option>
                    </select>
                </div>

                <div class="form-group">
                    <label for="diet">Do you follow any specific diet?</label>
                    <select id="diet" name="diet" required>
                        <option value="">--Select Option--</option>
                        <option value="Yes" <?php if(isset($diet) && $diet == 'Yes') echo 'selected'; ?>>Yes</option>
                        <option value="No" <?php if(isset($diet) && $diet == 'No') echo 'selected'; ?>>No</option>
                    </select>
                </div>

                <?php
                // Show diet_specify input if diet is 'Yes'
                if (isset($diet) && $diet === 'Yes') {
                    echo '<div class="form-group">';
                    echo '<label for="diet_specify">Please specify your diet:</label>';
                    echo '<input type="text" id="diet_specify" name="diet_specify" value="'.htmlspecialchars($diet_specify).'">';
                    echo '</div>';
                }
                ?>

                <div class="form-group">
                    <label for="sleep">How much sleep do you get on average?</label>
                    <select id="sleep" name="sleep" required>
                        <option value="">--Select Duration--</option>
                        <option value="<5 Hours" <?php if(isset($sleep) && $sleep == '<5 Hours') echo 'selected'; ?>>&lt;5 Hours</option>
                        <option value="5-7 Hours" <?php if(isset($sleep) && $sleep == '5-7 Hours') echo 'selected'; ?>>5-7 Hours</option>
                        <option value="7-9 Hours" <?php if(isset($sleep) && $sleep == '7-9 Hours') echo 'selected'; ?>>7-9 Hours</option>
                        <option value=">9 Hours" <?php if(isset($sleep) && $sleep == '>9 Hours') echo 'selected'; ?>>&gt;9 Hours</option>
                    </select>
                </div>

                <div class="form-group">
                    <label for="smoking">Smoking Status:</label>
                    <select id="smoking" name="smoking" required>
                        <option value="">--Select Option--</option>
                        <option value="Yes" <?php if(isset($smoking) && $smoking == 'Yes') echo 'selected'; ?>>Yes</option>
                        <option value="No" <?php if(isset($smoking) && $smoking == 'No') echo 'selected'; ?>>No</option>
                        <option value="Occasionally" <?php if(isset($smoking) && $smoking == 'Occasionally') echo 'selected'; ?>>Occasionally</option>
                    </select>
                </div>

                <input type="submit" value="Continue">
            </form>
        </div>
    </div>
</body>
</html>
Key Features:

Form Fields: Collects exercise_frequency, diet, diet_specify, sleep_average, and smoking_status.
Conditional Fields: diet_specify is displayed only if the user selects "Yes" for diet.
Data Association: Data is stored in the patient_health_metrics table, linked via patient_id from the session.
Error Handling: Displays errors if validation fails or if there's a database error.
5.6. Page 5: Medical History (pages/page5.php)
Purpose: Collect the patient's medical history.


<?php
// pages/page5.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 = [];

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    // Sanitize and validate inputs
    $chronic_conditions = isset($_POST['chronic_conditions']) ? htmlspecialchars(trim($_POST['chronic_conditions'])) : '';
    $chronic_conditions_specify = isset($_POST['chronic_conditions_specify']) ? htmlspecialchars(trim($_POST['chronic_conditions_specify'])) : '';
    $medications = isset($_POST['medications']) ? htmlspecialchars(trim($_POST['medications'])) : '';
    $medications_list = isset($_POST['medications_list']) ? htmlspecialchars(trim($_POST['medications_list'])) : '';
    $major_surgeries = isset($_POST['major_surgeries']) ? htmlspecialchars(trim($_POST['major_surgeries'])) : '';
    $major_surgeries_specify = isset($_POST['major_surgeries_specify']) ? htmlspecialchars(trim($_POST['major_surgeries_specify'])) : '';

    // Validate inputs
    if (empty($chronic_conditions)) {
        $errors[] = "Please specify if you have any chronic conditions.";
    }
    if ($chronic_conditions === 'Yes' && empty($chronic_conditions_specify)) {
        $errors[] = "Please specify your chronic conditions.";
    }
    if (empty($medications)) {
        $errors[] = "Please specify if you are taking any medications.";
    }
    if ($medications === 'Yes' && empty($medications_list)) {
        $errors[] = "Please list your medications.";
    }
    if (empty($major_surgeries)) {
        $errors[] = "Please specify if you have any history of major surgeries.";
    }
    if ($major_surgeries === 'Yes' && empty($major_surgeries_specify)) {
        $errors[] = "Please specify your major surgeries.";
    }

    if (empty($errors)) {
        try {
            // Check if medical_history already exists
            $stmt = $pdo->prepare("SELECT patient_id FROM patient_medical_history WHERE patient_id = ?");
            $stmt->execute([$_SESSION['patient_id']]);
            if ($stmt->rowCount() > 0) {
                // Update existing record
                $stmt = $pdo->prepare("
                    UPDATE patient_medical_history 
                    SET chronic_conditions = ?, chronic_conditions_specify = ?, medications = ?, medications_list = ?, major_surgeries = ?, major_surgeries_specify = ?
                    WHERE patient_id = ?
                ");
                $stmt->execute([
                    $chronic_conditions, 
                    $chronic_conditions_specify, 
                    $medications, 
                    $medications_list, 
                    $major_surgeries, 
                    $major_surgeries_specify, 
                    $_SESSION['patient_id']
                ]);
            } else {
                // Insert new record
                $stmt = $pdo->prepare("
                    INSERT INTO patient_medical_history 
                    (patient_id, chronic_conditions, chronic_conditions_specify, medications, medications_list, major_surgeries, major_surgeries_specify) 
                    VALUES (?, ?, ?, ?, ?, ?, ?)
                ");
                $stmt->execute([
                    $_SESSION['patient_id'], 
                    $chronic_conditions, 
                    $chronic_conditions_specify, 
                    $medications, 
                    $medications_list, 
                    $major_surgeries, 
                    $major_surgeries_specify
                ]);
            }
            header("Location: page6.php");
            exit();
        } catch (PDOException $e) {
            $errors[] = "Database Error: " . $e->getMessage();
        }
    }
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Medical History</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>Medical History</h2>
        </div>

        <div class="section">
            <h3>Medical History</h3>
            <p>Your current health condition matters.</p>

            <?php
            if (!empty($errors)) {
                echo '<div class="error">';
                foreach($errors as $error){
                    echo "<p>$error</p>";
                }
                echo '</div>';
            }
            ?>

            <form method="POST" action="">
                <!-- Chronic Conditions -->
                <div class="form-group">
                    <label for="chronic_conditions">Do you have any chronic conditions?</label>
                    <select id="chronic_conditions" name="chronic_conditions" required>
                        <option value="">--Select Option--</option>
                        <option value="Yes" <?php if(isset($chronic_conditions) && $chronic_conditions == 'Yes') echo 'selected'; ?>>Yes</option>
                        <option value="No" <?php if(isset($chronic_conditions) && $chronic_conditions == 'No') echo 'selected'; ?>>No</option>
                    </select>
                </div>

                <?php
                // Show specify input if chronic_conditions is 'Yes'
                if (isset($chronic_conditions) && $chronic_conditions === 'Yes') {
                    echo '<div class="form-group">';
                    echo '<label for="chronic_conditions_specify">Please specify your chronic conditions:</label>';
                    echo '<input type="text" id="chronic_conditions_specify" name="chronic_conditions_specify" value="'.htmlspecialchars($chronic_conditions_specify).'">';
                    echo '</div>';
                }
                ?>

                <!-- Medications -->
                <div class="form-group">
                    <label for="medications">Are you taking any medications?</label>
                    <select id="medications" name="medications" required>
                        <option value="">--Select Option--</option>
                        <option value="Yes" <?php if(isset($medications) && $medications == 'Yes') echo 'selected'; ?>>Yes</option>
                        <option value="No" <?php if(isset($medications) && $medications == 'No') echo 'selected'; ?>>No</option>
                    </select>
                </div>

                <?php
                // Show medications_list input if medications is 'Yes'
                if (isset($medications) && $medications === 'Yes') {
                    echo '<div class="form-group">';
                    echo '<label for="medications_list">Please list your medications:</label>';
                    echo '<textarea id="medications_list" name="medications_list" rows="4" required>'.htmlspecialchars($medications_list).'</textarea>';
                    echo '</div>';
                }
                ?>

                <!-- Major Surgeries -->
                <div class="form-group">
                    <label for="major_surgeries">Any history of major surgeries?</label>
                    <select id="major_surgeries" name="major_surgeries" required>
                        <option value="">--Select Option--</option>
                        <option value="Yes" <?php if(isset($major_surgeries) && $major_surgeries == 'Yes') echo 'selected'; ?>>Yes</option>
                        <option value="No" <?php if(isset($major_surgeries) && $major_surgeries == 'No') echo 'selected'; ?>>No</option>
                    </select>
                </div>

                <?php
                // Show major_surgeries_specify input if major_surgeries is 'Yes'
                if (isset($major_surgeries) && $major_surgeries === 'Yes') {
                    echo '<div class="form-group">';
                    echo '<label for="major_surgeries_specify">Please specify your major surgeries:</label>';
                    echo '<input type="text" id="major_surgeries_specify" name="major_surgeries_specify" value="'.htmlspecialchars($major_surgeries_specify).'">';
                    echo '</div>';
                }
                ?>

                <input type="submit" value="Continue">
            </form>
        </div>
    </div>

    <script>
        // Enable or disable specify fields based on selection
        document.getElementById('chronic_conditions').addEventListener('change', function() {
            var specifyInput = document.getElementById('chronic_conditions_specify');
            if (this.value === 'Yes') {
                specifyInput.disabled = false;
                specifyInput.required = true;
            } else {
                specifyInput.disabled = true;
                specifyInput.required = false;
                specifyInput.value = '';
            }
        });

        document.getElementById('medications').addEventListener('change', function() {
            var textarea = document.getElementById('medications_list');
            if (this.value === 'Yes') {
                textarea.disabled = false;
                textarea.required = true;
            } else {
                textarea.disabled = true;
                textarea.required = false;
                textarea.value = '';
            }
        });

        document.getElementById('major_surgeries').addEventListener('change', function() {
            var specifyInput = document.getElementById('major_surgeries_specify');
            if (this.value === 'Yes') {
                specifyInput.disabled = false;
                specifyInput.required = true;
            } else {
                specifyInput.disabled = true;
                specifyInput.required = false;
                specifyInput.value = '';
            }
        });
    </script>
</body>
</html>
Key Features:

Form Fields: Collects chronic_conditions, medications, and major_surgeries with conditional fields for specifications.
Data Association: Data is stored in the patient_medical_history table, linked via patient_id from the session.
Error Handling: Displays errors if validation fails or if there's a database error.
5.7. Page 6: Your Goals (pages/page6.php)
Purpose: Define the patient's health goals and areas of concern.


<?php
// pages/page6.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 = [];
$additional_goal = '';

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    // Sanitize and validate inputs
    $primary_goals = isset($_POST['primary_goals']) ? $_POST['primary_goals'] : [];
    $additional_goal = isset($_POST['additional_goal']) ? htmlspecialchars(trim($_POST['additional_goal'])) : '';
    $health_concerns = isset($_POST['health_concerns']) ? $_POST['health_concerns'] : [];

    // Validate inputs
    if (empty($primary_goals)) {
        $errors[] = "Please select at least one primary health goal.";
    }

    // If 'Other' is selected, ensure additional_goal is provided
    if (in_array('Other', $primary_goals) && empty($additional_goal)) {
        $errors[] = "Please specify your other health goal.";
    }

    if (empty($health_concerns)) {
        $errors[] = "Please select at least one area of health concern.";
    }

    if (empty($errors)) {
        try {
            // Process 'Other' goal
            $processed_goals = [];
            foreach ($primary_goals as $goal) {
                if ($goal === 'Other') {
                    $processed_goals[] = $additional_goal;
                } else {
                    $processed_goals[] = $goal;
                }
            }

            // Save to patient_goals table
            // Check if record exists
            $stmt = $pdo->prepare("SELECT patient_id FROM patient_goals WHERE patient_id = ?");
            $stmt->execute([$_SESSION['patient_id']]);
            if ($stmt->rowCount() > 0) {
                // Update existing record
                $stmt = $pdo->prepare("UPDATE patient_goals SET primary_health_goals = ?, health_concerns = ? WHERE patient_id = ?");
                $stmt->execute([
                    json_encode($processed_goals), 
                    json_encode($health_concerns), 
                    $_SESSION['patient_id']
                ]);
            } else {
                // Insert new record
                $stmt = $pdo->prepare("INSERT INTO patient_goals (patient_id, primary_health_goals, health_concerns) VALUES (?, ?, ?)");
                $stmt->execute([
                    $_SESSION['patient_id'], 
                    json_encode($processed_goals), 
                    json_encode($health_concerns)
                ]);
            }

            header("Location: page7.php");
            exit();
        } catch (PDOException $e) {
            $errors[] = "Database Error: " . $e->getMessage();
        }
    }
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Defining Your Health Goals</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>Defining Your Health Goals</h2>
        </div>

        <div class="section">
            <h3>Defining Your Health Goals</h3>
            <p>We tailor your journey based on what matters most to you.</p>

            <?php
            if (!empty($errors)) {
                echo '<div class="error">';
                foreach($errors as $error){
                    echo "<p>$error</p>";
                }
                echo '</div>';
            }
            ?>

            <form method="POST" action="">
                <!-- Primary Health Goals -->
                <div class="form-group">
                    <label for="primary_goals">What are your primary health goals?</label>
                    <select id="primary_goals" name="primary_goals[]" multiple size="4" required>
                        <option value="Improve energy" <?php if(isset($primary_goals) && in_array('Improve energy', $primary_goals)) echo 'selected'; ?>>Improve energy</option>
                        <option value="Lose weight" <?php if(isset($primary_goals) && in_array('Lose weight', $primary_goals)) echo 'selected'; ?>>Lose weight</option>
                        <option value="Reverse a chronic condition" <?php if(isset($primary_goals) && in_array('Reverse a chronic condition', $primary_goals)) echo 'selected'; ?>>Reverse a chronic condition</option>
                        <option value="Other" <?php if(isset($primary_goals) && in_array('Other', $primary_goals)) echo 'selected'; ?>>Other</option>
                    </select>
                </div>

                <?php
                // Show additional_goal input if 'Other' is selected
                if (isset($primary_goals) && in_array('Other', $primary_goals)) {
                    echo '<div class="form-group">';
                    echo '<label for="additional_goal">Please specify your other health goal:</label>';
                    echo '<input type="text" id="additional_goal" name="additional_goal" value="'.htmlspecialchars($additional_goal).'">';
                    echo '</div>';
                }
                ?>

                <!-- Health Concerns -->
                <div class="form-group">
                    <label for="health_concerns">What areas of your health concern you the most?</label>
                    <select id="health_concerns" name="health_concerns[]" multiple size="4" required>
                        <option value="Aging" <?php if(isset($health_concerns) && in_array('Aging', $health_concerns)) echo 'selected'; ?>>Aging</option>
                        <option value="Disease Prevention" <?php if(isset($health_concerns) && in_array('Disease Prevention', $health_concerns)) echo 'selected'; ?>>Disease Prevention</option>
                        <option value="Mental Health" <?php if(isset($health_concerns) && in_array('Mental Health', $health_concerns)) echo 'selected'; ?>>Mental Health</option>
                        <option value="Skin Health" <?php if(isset($health_concerns) && in_array('Skin Health', $health_concerns)) echo 'selected'; ?>>Skin Health</option>
                    </select>
                </div>

                <input type="submit" value="Continue">
            </form>
        </div>
    </div>

    <script>
        // Enable or disable additional_goal based on primary_goals selection
        document.getElementById('primary_goals').addEventListener('change', function() {
            var selectedOptions = Array.from(this.selectedOptions).map(option => option.value);
            var additionalGoalInput = document.getElementById('additional_goal');
            if (selectedOptions.includes('Other')) {
                additionalGoalInput.disabled = false;
                additionalGoalInput.required = true;
            } else {
                additionalGoalInput.disabled = true;
                additionalGoalInput.required = false;
                additionalGoalInput.value = '';
            }
        });
    </script>
</body>
</html>
Key Features:

Primary Health Goals: Multi-select allows users to choose multiple goals.
Health Concerns: Multi-select allows users to highlight multiple areas of concern.
Conditional Fields: additional_goal is displayed only if "Other" is selected in primary goals.
Data Association: Data is stored in the patient_goals table, linked via patient_id from the session.
Error Handling: Displays errors if validation fails or if there's a database error.
5.7. Page 7: The Longeva Approach (pages/page7.php)
Purpose: Inform the user about Longeva’s integrated approach. No data collection on this page.


<?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();
}

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    // Redirect to next page
    header("Location: page8.php");
    exit();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>The Longeva Approach</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>The Longeva Approach</h2>
        </div>

        <div class="section">
            <h3>Longeva’s Integrated Approach</h3>
            <p>We use precision cellular medicine and personalized treatments to reverse chronic conditions and slow aging. Our team will develop a tailored strategy to enhance your health using cutting-edge cellular technology.</p>
            <form method="POST" action="">
                <input type="submit" value="Learn More">
            </form>
        </div>
    </div>
</body>
</html>
Key Features:

Informational Content: Educates the user about Longeva’s approach.
Navigation Button: Allows users to proceed to the next part of the questionnaire.
5.8. Page 8: Longeva Programs Overview (pages/page8.php)
Purpose: Present available programs. Users can choose to continue to the consultation.


<?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 = [];

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    // For simplicity, proceed to consultation without selecting specific programs
    header("Location: page9.php");
    exit();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Explore Our Programs</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>Explore Our Programs</h2>
        </div>

        <div class="section">
            <h3>Explore Our Programs</h3>
            <p>We offer various programs designed to target chronic conditions and optimize health:</p>
            <ul>
                <li><strong>Age Reversal & Skin Enhancement:</strong> Comprehensive treatments to rejuvenate your skin and reverse aging signs.</li>
                <li><strong>Reversal of Diabetes & Obesity:</strong> Targeted therapies to manage and reverse these chronic conditions.</li>
                <li><strong>Non-Surgical Lifting:</strong> Advanced non-invasive techniques for body contouring and lifting.</li>
                <li><strong>And more...</strong></li>
            </ul>
            <form method="POST" action="">
                <input type="submit" value="Continue">
            </form>
        </div>
    </div>
</body>
</html>
Key Features:

Program Descriptions: Clearly outlines the available health programs.
Navigation Button: Allows users to proceed to the personalized consultation.
Note: If you wish to allow users to select specific programs, you can add corresponding form fields and store their selections in a new table (e.g., patient_programs). For simplicity, this example proceeds without capturing program selections.

5.9. Page 9: Personalized Consultation (pages/page9.php)
Purpose: Schedule a personalized consultation.


<?php
// pages/page9.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';

$errors = [];
$scheduled_at = '';

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    // Sanitize and validate input
    $scheduled_at = isset($_POST['scheduled_at']) ? htmlspecialchars(trim($_POST['scheduled_at'])) : '';

    if (empty($scheduled_at)) {
        $errors[] = "Please select a consultation date and time.";
    } else {
        // Validate datetime format
        $date = DateTime::createFromFormat('Y-m-d\TH:i', $scheduled_at);
        if (!$date) {
            $errors[] = "Invalid date and time format.";
        }
    }

    if (empty($errors)) {
        try {
            // Save to patient_consultation table
            // Check if record exists
            $stmt = $pdo->prepare("SELECT patient_id FROM patient_consultation WHERE patient_id = ?");
            $stmt->execute([$_SESSION['patient_id']]);
            if ($stmt->rowCount() > 0) {
                // Update existing record
                $stmt = $pdo->prepare("UPDATE patient_consultation SET scheduled_at = ? WHERE patient_id = ?");
                $stmt->execute([$scheduled_at, $_SESSION['patient_id']]);
            } else {
                // Insert new record
                $stmt = $pdo->prepare("INSERT INTO patient_consultation (patient_id, scheduled_at) VALUES (?, ?)");
                $stmt->execute([$_SESSION['patient_id'], $scheduled_at]);
            }

            header("Location: page10.php");
            exit();
        } catch (PDOException $e) {
            $errors[] = "Database Error: " . $e->getMessage();
        }
    }
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Personalized Consultation</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>Personalized Consultation</h2>
        </div>

        <div class="section">
            <h3>Personalized Consultation</h3>
            <p>Your answers help us tailor your health journey. Next, you’ll receive a personalized consultation and diagnostic tests. Our team will visit you for a detailed consultation and telomere test.</p>

            <?php
            if (!empty($errors)) {
                echo '<div class="error">';
                foreach($errors as $error){
                    echo "<p>$error</p>";
                }
                echo '</div>';
            }
            ?>

            <form method="POST" action="">
                <div class="form-group">
                    <label for="scheduled_at">Select Consultation Date and Time:</label>
                    <input type="datetime-local" id="scheduled_at" name="scheduled_at" value="<?php echo htmlspecialchars($scheduled_at); ?>" required>
                </div>
                <input type="submit" value="Schedule Your Consultation">
            </form>
        </div>
    </div>
</body>
</html>
Key Features:

Form Field: Allows users to select a preferred date and time for their consultation.
Data Association: Scheduled consultation datetime is stored in the patient_consultation table, linked via patient_id from the session.
Error Handling: Displays errors if validation fails or if there's a database error.
Note: Ensure your server’s timezone settings match your target audience or handle timezone conversions as necessary.

5.10. Page 10: Final Page (pages/page10.php)
Purpose: Confirm completion and provide a button to return to the homepage.


<?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();
}

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    // Optionally, perform any final data processing

    // Destroy the session to end the questionnaire
    session_destroy();

    // Redirect to thank_you.php
    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="">
                <input type="submit" value="Return to Homepage">
            </form>
        </div>
    </div>
</body>
</html>
Key Features:

Confirmation Message: Informs users that their questionnaire is complete and that they will be contacted soon.
Return Button: Redirects users back to the homepage.
Session Handling: Destroys the session to ensure data security and privacy after completion.
6. Thank You Page (thank_you.php)
Purpose: Display a thank you message after completing the questionnaire.


<?php
// thank_you.php

// Start session
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!</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>
            <a href="index.php" class="back-link">Return to Homepage</a>
        </div>
    </div>
</body>
</html>) ,when enter all info until 6 pages, next page show his/her anaylsis info (like bmi and other things are useful) and after that show page about details and ask her/him if you want to get appointment or get return home and make it cool design and this public_appointment.php codes (<?php
// Include database connection
require_once '../db_connect.php'; // Adjust the path if necessary

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

// Autoload PHPMailer classes (if using Composer)
require '../vendor/autoload.php'; // Adjust the path to autoload.php

// Verify that $conn is defined
if (!isset($conn)) {
    die("Database connection not established. Please check db_connect.php.");
}

// Initialize variables
$success = '';
$errors = [];

// Fetch packages for the form and JavaScript
$packages = [];

// Fetch packages from the database
$packageQuery = "SELECT id, package_name, description FROM packages";
$packageResult = $conn->query($packageQuery);

// Check for query error
if ($packageResult) {
    while ($row = $packageResult->fetch_assoc()) {
        $packages[] = $row;
    }
} else {
    $errors[] = "Failed to fetch packages: " . $conn->error;
}

// Handle form submission
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    // Collect input data
    $name = trim($_POST['name']);
    $email = trim($_POST['email']);
    $phone = trim($_POST['phone']);
    $age = intval($_POST['age']);
    $gender = $_POST['gender'];
    $address = trim($_POST['address']);
    $preferred_contact_method = $_POST['preferred_contact_method'];
    $package_id = $_POST['package_id'];
    $appointment_date = $_POST['appointment_date'];
    $additional_notes = trim($_POST['additional_notes']);

    // Validate inputs
    if (empty($name)) {
        $errors[] = "Please provide your full name.";
    }
    if (empty($email)) {
        $errors[] = "Please provide your email address.";
    }
    if (empty($phone)) {
        $errors[] = "Please provide your phone number.";
    }
    if (empty($age) || $age <= 0) {
        $errors[] = "Please provide a valid age.";
    }
    if (empty($gender)) {
        $errors[] = "Please select your gender.";
    }
    if (empty($address)) {
        $errors[] = "Please provide your address.";
    }
    if (empty($preferred_contact_method)) {
        $errors[] = "Please select your preferred contact method.";
    }
    if (empty($appointment_date)) {
        $errors[] = "Please select a preferred appointment date and time.";
    }
    if (empty($package_id)) {
        $errors[] = "Please select a package.";
    }

    // Ensure the appointment date is in the future
    $appointment_datetime = new DateTime($appointment_date);
    $current_datetime = new DateTime();
    if ($appointment_datetime <= $current_datetime) {
        $errors[] = "Please select a future date and time for your appointment.";
    }

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

        // Prepare and execute the availability query
        $availabilityQuery = "
            SELECT COUNT(*) as count FROM appointments
            WHERE appointment_date < ? AND DATE_ADD(appointment_date, INTERVAL ? MINUTE) > ?
        ";
        $stmt = $conn->prepare($availabilityQuery);
        if ($stmt) {
            $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->bind_param("sis", $appointment_end_str, $duration, $appointment_start_str);
            $stmt->execute();
            $stmt->bind_result($count);
            $stmt->fetch();
            $stmt->close();

            if ($count > 0) {
                $errors[] = "The selected time slot is not available. Please choose a different time.";
            }
        } else {
            $errors[] = "Database error during availability check: " . $conn->error;
        }
    }

    if (empty($errors)) {
        // Insert appointment
        $insertQuery = "INSERT INTO appointments
            (package_id, appointment_date, name, email, phone, age, gender, address, preferred_contact_method, additional_notes)
            VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
        $stmt = $conn->prepare($insertQuery);
        if ($stmt) {
            $appointment_date_str = $appointment_datetime->format('Y-m-d H:i:s');
            $stmt->bind_param(
                "isssisssss",
                $package_id,
                $appointment_date_str,
                $name,
                $email,
                $phone,
                $age,
                $gender,
                $address,
                $preferred_contact_method,
                $additional_notes
            );
            if ($stmt->execute()) {
                // Retrieve the last inserted appointment ID
                $appointment_id = $conn->insert_id;
                $success = "Appointment requested successfully! We will contact you soon to confirm the details.";

                // Fetch selected package name for email
                $stmt_pkg = $conn->prepare("SELECT package_name FROM packages WHERE id = ?");
                if ($stmt_pkg) {
                    $stmt_pkg->bind_param("i", $package_id);
                    $stmt_pkg->execute();
                    $stmt_pkg->bind_result($package_name);
                    $stmt_pkg->fetch();
                    $stmt_pkg->close();

                    // 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($email, $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;
                                }
                                .email-body h2 {
                                    color: #4F3F02;
                                    margin-top: 0;
                                }
                                .email-body p {
                                    line-height: 1.6;
                                }
                                .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($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($name, ENT_QUOTES, 'UTF-8') . '</p>
                                        <p><strong>Email:</strong> ' . htmlspecialchars($email, ENT_QUOTES, 'UTF-8') . '</p>
                                        <p><strong>Phone:</strong> ' . htmlspecialchars($phone, ENT_QUOTES, 'UTF-8') . '</p>
                                        <p><strong>Age:</strong> ' . htmlspecialchars($age, ENT_QUOTES, 'UTF-8') . '</p>
                                        <p><strong>Gender:</strong> ' . htmlspecialchars($gender, ENT_QUOTES, 'UTF-8') . '</p>
                                        <p><strong>Address:</strong> ' . htmlspecialchars($address, ENT_QUOTES, 'UTF-8') . '</p>
                                        <p><strong>Preferred Contact Method:</strong> ' . htmlspecialchars($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_date_str)) . '</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>

                                    <p>Warm regards,<br>The Longeva Health Center Team</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 ' . $name . ',

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

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

Appointment Details:
Appointment ID: ' . $conn->insert_id . '
Package Selected: ' . $package_name . '
Preferred Date & Time: ' . date('l, F j, Y \a\t g:i A', strtotime($appointment_date_str)) . '

' . (!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,
The 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;
                    }

                } else {
                    $errors[] = "Failed to fetch package details for email: " . $conn->error;
                }
            } else {
                $errors[] = "Error scheduling appointment: " . $stmt->error;
            }
            $stmt->close();
        } else {
            $errors[] = "Database error during appointment scheduling: " . $conn->error;
        }
    }
}
?>

<!DOCTYPE html>
<html>
<head>
    <title>Request Appointment - Longeva</title>
    <!-- Include Bootstrap CSS -->
    <!-- Using Bootstrap 4.5.2 -->
    <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="../images/white-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' 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' onclick=\"window.location.href='public_appointment.php';\">
                              <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' onclick=\"window.location.href='public_appointment.php';\">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="name">Full Name</label>
                        <input type="text" name="name" class="form-control" placeholder="Enter your full name" required/>
                    </div>
                    <div class="form-group">
                        <label for="email">Email Address</label>
                        <input type="email" name="email" class="form-control" placeholder="Enter your email address" required/>
                    </div>
                    <div class="form-group">
                        <label for="phone">Phone Number</label>
                        <input type="text" name="phone" class="form-control" placeholder="Enter your phone number" required/>
                    </div>
                    <div class="form-group">
                        <label for="age">Age</label>
                        <input type="number" name="age" min="0" class="form-control" placeholder="Enter your age" required/>
                    </div>
                    <div class="form-group">
                        <label for="gender">Gender</label>
                        <select name="gender" class="form-control" required>
                            <option value="">Select Gender</option>
                            <option value="Male">Male</option>
                            <option value="Female">Female</option>
                            <option value="Other">Other</option>
                        </select>
                    </div>
                    <div class="form-group">
                        <label for="address">Address</label>
                        <input type="text" name="address" class="form-control" placeholder="Enter your address" required/>
                    </div>
                    <div class="form-group">
                        <label for="preferred_contact_method">Preferred Contact Method</label>
                        <select name="preferred_contact_method" class="form-control" required>
                            <option value="">Select Preferred Contact Method</option>
                            <option value="Email">Email</option>
                            <option value="Phone">Phone</option>
                            <option value="WhatsApp">WhatsApp</option>
                        </select>
                    </div>
                    <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) {
                                echo "<option value='" . $pkg['id'] . "'>" . htmlspecialchars($pkg['package_name']) . "</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" 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"></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';
                }
            } else {
                packageDetailsDiv.style.display = 'none';
            }
        }

        $(document).ready(function() {
            // Show the success modal if success message is set
            <?php if (!empty($success)) { ?>
                $('#successModal').modal('show');
            <?php } ?>
        });
    </script>
</body>
</html>) the path (../../appointment/public_appointment.php) and if she/he choose appintment, in page add info that entered in the last pages (gender and age) and type full codes with guides, and make sure when submit the appointment make sure the id patient with info that entered the info and update databsae  and make it cool design and this info of database (-- phpMyAdmin SQL Dump
-- version 5.2.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1:3306
-- Generation Time: Oct 16, 2024 at 09:37 AM
-- 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";

--
-- 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,
  `admin_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(3) DEFAULT NULL,
  `gender` enum('Male','Female','Other') DEFAULT 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_basic_info`
--

CREATE TABLE `patient_basic_info` (
  `patient_id` int(11) NOT NULL,
  `gender` enum('Male','Female','Other') NOT NULL,
  `age` int(3) NOT NULL,
  `weight` decimal(5,2) NOT NULL,
  `height` decimal(5,2) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `patient_consent`
--

CREATE TABLE `patient_consent` (
  `patient_id` int(11) NOT NULL,
  `consent` enum('accepted','declined') NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `patient_consultation`
--

CREATE TABLE `patient_consultation` (
  `patient_id` int(11) NOT NULL,
  `scheduled_at` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `patient_goals`
--

CREATE TABLE `patient_goals` (
  `patient_id` int(11) NOT NULL,
  `primary_health_goals` text NOT NULL,
  `health_concerns` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `patient_health_metrics`
--

CREATE TABLE `patient_health_metrics` (
  `patient_id` int(11) NOT NULL,
  `exercise_frequency` enum('Daily','Weekly','Rarely','Never') NOT NULL,
  `diet` enum('Yes','No') NOT NULL,
  `diet_specify` varchar(255) DEFAULT NULL,
  `sleep_average` enum('<5 Hours','5-7 Hours','7-9 Hours','>9 Hours') NOT NULL,
  `smoking_status` enum('Yes','No','Occasionally') NOT 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 `patient_medical_history`
--

CREATE TABLE `patient_medical_history` (
  `patient_id` int(11) NOT NULL,
  `chronic_conditions` enum('Yes','No') NOT NULL,
  `chronic_conditions_specify` varchar(255) DEFAULT NULL,
  `medications` enum('Yes','No') NOT NULL,
  `medications_list` text DEFAULT NULL,
  `major_surgeries` enum('Yes','No') NOT NULL,
  `major_surgeries_specify` varchar(255) DEFAULT 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 `questionnaire_responses`
--

CREATE TABLE `questionnaire_responses` (
  `id` int(11) NOT NULL,
  `session_id` varchar(255) NOT NULL,
  `page_number` int(2) NOT NULL,
  `question` varchar(255) NOT NULL,
  `answer` text NOT NULL,
  `submitted_at` timestamp NULL DEFAULT current_timestamp(),
  `consent` enum('Yes','No') DEFAULT 'No'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_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_basic_info`
--
ALTER TABLE `patient_basic_info`
  ADD PRIMARY KEY (`patient_id`);

--
-- Indexes for table `patient_consent`
--
ALTER TABLE `patient_consent`
  ADD PRIMARY KEY (`patient_id`);

--
-- Indexes for table `patient_consultation`
--
ALTER TABLE `patient_consultation`
  ADD PRIMARY KEY (`patient_id`);

--
-- Indexes for table `patient_goals`
--
ALTER TABLE `patient_goals`
  ADD PRIMARY KEY (`patient_id`);

--
-- Indexes for table `patient_health_metrics`
--
ALTER TABLE `patient_health_metrics`
  ADD PRIMARY KEY (`patient_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 `patient_medical_history`
--
ALTER TABLE `patient_medical_history`
  ADD PRIMARY KEY (`patient_id`);

--
-- 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 `questionnaire_responses`
--
ALTER TABLE `questionnaire_responses`
  ADD PRIMARY KEY (`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 `questionnaire_responses`
--
ALTER TABLE `questionnaire_responses`
  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_basic_info`
--
ALTER TABLE `patient_basic_info`
  ADD CONSTRAINT `patient_basic_info_ibfk_1` FOREIGN KEY (`patient_id`) REFERENCES `patients` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

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

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

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

--
-- Constraints for table `patient_health_metrics`
--
ALTER TABLE `patient_health_metrics`
  ADD CONSTRAINT `patient_health_metrics_ibfk_1` FOREIGN KEY (`patient_id`) REFERENCES `patients` (`id`) ON DELETE CASCADE 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 `patient_medical_history`
--
ALTER TABLE `patient_medical_history`
  ADD CONSTRAINT `patient_medical_history_ibfk_1` FOREIGN KEY (`patient_id`) REFERENCES `patients` (`id`) ON DELETE CASCADE ON UPDATE 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;
),  i wnat you to change totall and i don't want public appoinmtnet and make, different way and add more features and make it looks amazing and tell me the full guides