🚀 Hostinger Optimized
🖥️ Server: LiteSpeed
💻 System: Linux in-mum-web1643.main-hosting.eu 5.14.0-611.42.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Mar 24 05:30:20 EDT 2026 x86_64
👤 User: u621169360 (621169360)
🐘 PHP: 8.2.30
🚫 Disabled: system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail

💻 Terminal

📁 /home/u621169360/domains/agriexpertt.com/public_html
$

📄 Host-Training.php

📁 Path: /home/u621169360/domains/agriexpertt.com/public_html/corporate-admin/functions/Host-Training.php
📊 Size: 34.5 KB
🔒 Perm: 0644
📝 MIME: text/x-php
<?php
// Enable error reporting for debugging
error_reporting(E_ALL);
ini_set('display_errors', 1);

// Training Management Page

$table_name = 'trainings';
$redirection_page = "index.php?action=$page_name";
$action_name = "action=$page_name";
$type = $_REQUEST['type'] ?? null;
$edit_id = $_REQUEST['edit_id'] ?? null;
$delete_id = $_REQUEST['delete_id'] ?? null;

// Logging function
function logError($message) {
    error_log($message, 3, 'training_management_errors.log');
}

// Handle Image Upload for Training
function uploadTrainingImage($file) {
    if (!$file || $file['error'] !== UPLOAD_ERR_OK) {
        logError("Image upload error: " . $file['error']);
        return null;
    }

    $upload_dir = 'uploads/trainings/';
    if (!is_dir($upload_dir)) {
        mkdir($upload_dir, 0755, true);
    }

    $filename = uniqid() . '_' . basename($file['name']);
    $upload_path = $upload_dir . $filename;
    
    if (move_uploaded_file($file['tmp_name'], $upload_path)) {
        // Get the full URL of the uploaded image
        $base_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . 
                    "://$_SERVER[HTTP_HOST]" . 
                    dirname($_SERVER['PHP_SELF']) . '/';
        
        return $base_url . $upload_path;
    }
    
    logError("Failed to move uploaded file");
    return null;
}

// Handle Form Submission
if (isset($_POST['submit'])) {
    try {
        // Collect form data with additional validation
        $title = trim($_POST['title'] ?? '');
        $date = $_POST['date'] ?? null;
        $time = $_POST['time'] ?? null;
        $location = trim($_POST['location'] ?? '');
        $description = trim($_POST['description'] ?? '');
        $fees = floatval($_POST['fees'] ?? 0);
        $trainer_name = trim($_POST['trainer_name'] ?? '');
        $max_participants = intval($_POST['max_participants'] ?? 0);
        $training_type = $_POST['training_type'] ?? 'offline';
        $difficulty_level = $_POST['difficulty_level'] ?? 'beginner';
        $category = trim($_POST['category'] ?? '');
        $registration_start_date = $_POST['registration_start_date'] ?? null;
        $registration_end_date = $_POST['registration_end_date'] ?? null;
        $status = $_POST['status'] ?? 'upcoming';

        // Validate required fields
        if (empty($title) || empty($date) || empty($time) || empty($location)) {
            throw new Exception("Missing required fields");
        }

        // Handle image upload
        $training_image = null;
        if (!empty($_FILES['training_image']['name'])) {
            $training_image = uploadTrainingImage($_FILES['training_image']);
        } elseif ($type == 'Edit' && !empty($_POST['existing_image'])) {
            // Keep existing image if no new image is uploaded
            $training_image = $_POST['existing_image'];
        }

        // Prepare database connection
        if (!$dbconn) {
            throw new Exception("Database connection not established");
        }

        if ($type == 'Edit' && $edit_id) {
            // Update existing record
            $update_query = "UPDATE `$table_name` SET 
                title = :title,
                date = :date,
                time = :time,
                location = :location,
                description = :description,
                fees = :fees,
                trainer_name = :trainer_name,
                max_participants = :max_participants,
                training_type = :training_type,
                difficulty_level = :difficulty_level,
                category = :category,
                registration_start_date = :registration_start_date,
                registration_end_date = :registration_end_date,
                status = :status,
                training_image = :training_image
                WHERE id = :edit_id";

            $stmt = $dbconn->prepare($update_query);
        } else {
            // Insert new record
            $insert_query = "INSERT INTO `$table_name` SET 
                title = :title,
                date = :date,
                time = :time,
                location = :location,
                description = :description,
                fees = :fees,
                trainer_name = :trainer_name,
                max_participants = :max_participants,
                training_type = :training_type,
                difficulty_level = :difficulty_level,
                category = :category,
                registration_start_date = :registration_start_date,
                registration_end_date = :registration_end_date,
                status = :status,
                training_image = :training_image,
                created_at = CURRENT_TIMESTAMP";

            $stmt = $dbconn->prepare($insert_query);
        }

        // Bind parameters
        $stmt->bindParam(':title', $title);
        $stmt->bindParam(':date', $date);
        $stmt->bindParam(':time', $time);
        $stmt->bindParam(':location', $location);
        $stmt->bindParam(':description', $description);
        $stmt->bindParam(':fees', $fees);
        $stmt->bindParam(':trainer_name', $trainer_name);
        $stmt->bindParam(':max_participants', $max_participants);
        $stmt->bindParam(':training_type', $training_type);
        $stmt->bindParam(':difficulty_level', $difficulty_level);
        $stmt->bindParam(':category', $category);
        $stmt->bindParam(':registration_start_date', $registration_start_date);
        $stmt->bindParam(':registration_end_date', $registration_end_date);
        $stmt->bindParam(':status', $status);
        $stmt->bindParam(':training_image', $training_image);

        // For update, add edit_id parameter
        if ($type == 'Edit' && $edit_id) {
            $stmt->bindParam(':edit_id', $edit_id);
        }

        // Execute the statement
        $result = $stmt->execute();

        if (!$result) {
            // Log detailed error information
            $errorInfo = $stmt->errorInfo();
            logError("Database Error: " . print_r($errorInfo, true));
            throw new Exception("Failed to save training: " . $errorInfo[2]);
        }

        $message = ($type == 'Edit' ? "Training updated" : "Training added") . " successfully.";
        $status = "success";

        // Redirect
        header("Location: $redirection_page");
        exit();

    } catch (Exception $e) {
        // Log the full error
        logError("Training Submission Error: " . $e->getMessage());
        
        // Set error message
        $message = "Error: " . $e->getMessage();
        $status = "error";
    }
}

// Pagination and Filtering
$pageno = $_GET['pageno'] ?? 1;
$no_of_records_per_page = 10;
$offset = ($pageno - 1) * $no_of_records_per_page;

// Filter and Search Parameters
$filter_type = $_GET['filter_type'] ?? null;
$filter_status = $_GET['filter_status'] ?? null;
$filter_category = $_GET['filter_category'] ?? null;
$search_query = $_GET['search'] ?? null;

// Build Dynamic Query with Filters
$where_clauses = [];
$params = [];

if ($filter_type) {
    $where_clauses[] = "training_type = :type";
    $params[':type'] = $filter_type;
}

if ($filter_status) {
    $where_clauses[] = "status = :status";
    $params[':status'] = $filter_status;
}

if ($filter_category) {
    $where_clauses[] = "category = :category";
    $params[':category'] = $filter_category;
}

if ($search_query) {
    $where_clauses[] = "(title LIKE :search OR trainer_name LIKE :search OR location LIKE :search)";
    $params[':search'] = "%$search_query%";
}

$where_sql = $where_clauses ? "WHERE " . implode(" AND ", $where_clauses) : "";

// Count total filtered rows
$count_query = "SELECT COUNT(*) FROM $table_name $where_sql";
$count_stmt = $dbconn->prepare($count_query);
foreach ($params as $key => $value) {
    $count_stmt->bindValue($key, $value);
}
$count_stmt->execute();
$total_rows = $count_stmt->fetchColumn();
$total_pages = ceil($total_rows / $no_of_records_per_page);

// Fetch Trainings with Filtering
$select_query = "SELECT * FROM $table_name 
    $where_sql 
    ORDER BY date DESC 
    LIMIT $offset, $no_of_records_per_page";
$stmt = $dbconn->prepare($select_query);
foreach ($params as $key => $value) {
    $stmt->bindValue($key, $value);
}
$stmt->execute();
$trainings = $stmt->fetchAll(PDO::FETCH_OBJ);

// Fetch specific training for editing
$edit_training = null;
if ($type == 'Edit' && $edit_id) {
    $select_edit = "SELECT * FROM $table_name WHERE id = :edit_id";
    $stmt = $dbconn->prepare($select_edit);
    $stmt->bindParam(':edit_id', $edit_id);
    $stmt->execute();
    $edit_training = $stmt->fetch(PDO::FETCH_OBJ);
}

// Fetch unique categories for filtering
$categories_query = "SELECT DISTINCT category FROM $table_name ORDER BY category";
$categories_stmt = $dbconn->prepare($categories_query);
$categories_stmt->execute();
$categories = $categories_stmt->fetchAll(PDO::FETCH_COLUMN);


$today = date('d/m/Y');

// Create the password string
$passwordString = 'AGRIEXPERT-' . $today;

// Generate MD5 hash
$md5Password = md5($passwordString);
?>

<?php if ($type == 'Delete') {
                // Soft delete
                $delete_statement = "DELETE FROM `$table_name` WHERE id = :delete_id";
                $stmt = $dbconn->prepare($delete_statement);
                $stmt->bindParam(':delete_id', $delete_id);
                $stmt->execute();

                $message = "Partner record successfully deleted.";
                $status = "success";
                header("Location: $redirection_page");
            }
            
            ?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Training Management</title>
    <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css" rel="stylesheet">
    <style>
        .preview-image {
            max-width: 200px;
            max-height: 200px;
            margin-top: 10px;
        }
        .truncate {
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            max-width: 200px;
        }
    </style>
</head>
<body>
<div class="container-fluid">
    <div class="content-wrapper">
        <div class="container-fluid">
            <!-- Breadcrumb -->
            <div class="row pt-2 pb-2">
                <div class="col-sm-9">
                    <h4 class="page-title">Training Management</h4>
                    <ol class="breadcrumb">
                        <li class="breadcrumb-item"><a href="index.php?action=Welcome">Dashboard</a></li>
                        <li class="breadcrumb-item active" aria-current="page">
                            <a href="<?php echo $redirection_page; ?>">Trainings</a>
                        </li>
                    </ol>
                </div>
            </div>

            <div class="row">
                <!-- Form Section -->
                <div class="col-lg-4">
                    <div class="card">
                        <div class="card-header">
                            <i class="fa fa-plus"></i> 
                            <?php echo ($type == 'Edit' ? 'Edit' : 'Add New') . ' Training'; ?>
                        </div>
                        <div class="card-body">
                            <?php 
                            // Display error message if exists
                            if (isset($message) && $status == 'error'): ?>
                                <div class="alert alert-danger alert-dismissible fade show" role="alert">
                                    <?php echo htmlspecialchars($message); ?>
                                    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                                        <span aria-hidden="true">&times;</span>
                                    </button>
                                </div>
                            <?php endif; ?>

                            <form method="POST" action="" enctype="multipart/form-data">
                                <!-- Hidden ID for updates -->
                                <input type="hidden" name="id" value="<?php echo $edit_training ? $edit_training->id : ''; ?>">
                                
                                <!-- Existing Image (if any) -->
                                <?php if ($edit_training && $edit_training->training_image): ?>
                                    <input type="hidden" name="existing_image" value="<?php echo htmlspecialchars($edit_training->training_image); ?>">
                                    <div class="form-group">
                                        <label>Current Image</label>
                                        <img src="<?php echo htmlspecialchars($edit_training->training_image); ?>" class="preview-image img-fluid">
                                    </div>
                                <?php endif; ?>

                                <!-- Title -->
                                <div class="form-group">
                                    <label>Title</label>
                                    <input type="text" name="title" class="form-control" 
                                           value="<?php echo $edit_training ? htmlspecialchars($edit_training->title) : ''; ?>" 
                                           required>
                                </div>

                                <!-- Date -->
                                <div class="form-group">
                                    <label>Date</label>
                                    <input type="text" name="date" class="form-control datepicker" 
                                           value="<?php echo $edit_training ? date('Y-m-d', strtotime($edit_training->date)) : ''; ?>" 
                                           required>
                                </div>

                                <!-- Time -->
                                <div class="form-group">
                                    <label>Time</label>
                                    <input type="text" name="time" class="form-control timepicker" 
                                           value="<?php echo $edit_training ? date('H:i', strtotime($edit_training->time)) : ''; ?>" 
                                           required>
                                </div>

                                <!-- Location -->
                                <div class="form-group">
                                    <label>Location</label>
                                    <input type="text" name="location" class="form-control" 
                                           value="<?php echo $edit_training ? htmlspecialchars($edit_training->location) : ''; ?>" 
                                           required>
                                </div>

                                <!-- Description -->
                                <div class="form-group">
                                    <label>Description</label>
                                    <textarea name="description" class="form-control" rows="3" required><?php 
                                        echo $edit_training ? htmlspecialchars($edit_training->description) : ''; 
                                    ?></textarea>
                                </div>

                                <!-- Fees -->
                                <div class="form-group">
                                    <label>Fees (₹)</label>
                                    <input type="number" name="fees" class="form-control" 
                                           value="<?php echo $edit_training ? $edit_training->fees : '0'; ?>" 
                                           min="0" step="0.01" required>
                                </div>

                                <!-- Trainer Name -->
                                <div class="form-group">
                                    <label>Trainer Name</label>
                                    <input type="text" name="trainer_name" class="form-control" 
                                           value="<?php echo $edit_training ? htmlspecialchars($edit_training->trainer_name) : ''; ?>">
                                </div>

                                <!-- Max Participants -->
                                <div class="form-group">
                                    <label>Max Participants</label>
                                    <input type="number" name="max_participants" class="form-control" 
                                           value="<?php echo $edit_training ? $edit_training->max_participants : ''; ?>" 
                                           min="1">
                                </div>

                                <!-- Training Type -->
                                <div class="form-group">
                                    <label>Training Type</label>
                                    <select name="training_type" class="form-control" required>
                                        <option value="offline" <?php echo ($edit_training && $edit_training->training_type == 'offline') ? 'selected' : ''; ?>>Offline</option>
                                        <option value="online" <?php echo ($edit_training && $edit_training->training_type == 'online') ? 'selected' : ''; ?>>Online</option>
                                        <option value="hybrid" <?php echo ($edit_training && $edit_training->training_type == 'hybrid') ? 'selected' : ''; ?>>Hybrid</option>
                                    </select>
                                </div>

                                <!-- Difficulty Level -->
                                <div class="form-group">
                                    <label>Difficulty Level</label>
                                    <select name="difficulty_level" class="form-control" required>
                                        <option value="beginner" <?php echo ($edit_training && $edit_training->difficulty_level == 'beginner') ? 'selected' : ''; ?>>Beginner</option>
                                        <option value="intermediate" <?php echo ($edit_training && $edit_training->difficulty_level == 'intermediate') ? 'selected' : ''; ?>>Intermediate</option>
                                        <option value="advanced" <?php echo ($edit_training && $edit_training->difficulty_level == 'advanced') ? 'selected' : ''; ?>>Advanced</option>
                                    </select>
                                </div>

                                <!-- Category -->
                                <div class="form-group">
                                    <label>Category</label>
                                    <input type="text" name="category" class="form-control" 
                                           value="<?php echo $edit_training ? htmlspecialchars($edit_training->category) : ''; ?>">
                                </div>

                                <!-- Registration Start Date -->
                                <div class="form-group">
                                    <label>Registration Start Date</label>
                                    <input type="text" name="registration_start_date" class="form-control datepicker" 
                                           value="<?php echo $edit_training && $edit_training->registration_start_date ? 
                                                    date('Y-m-d', strtotime($edit_training->registration_start_date)) : ''; ?>">
                                </div>

                                <!-- Registration End Date -->
                                <div class="form-group">
                                    <label>Registration End Date</label>
                                    <input type="text" name="registration_end_date" class="form-control datepicker" 
                                           value="<?php echo $edit_training && $edit_training->registration_end_date ? 
                                                    date('Y-m-d', strtotime($edit_training->registration_end_date)) : ''; ?>">
                                </div>

                                <!-- Status -->
                                <div class="form-group">
                                    <label>Status</label>
                                    <select name="status" class="form-control" required>
                                        <option value="upcoming" <?php echo ($edit_training && $edit_training->status == 'upcoming') ? 'selected' : ''; ?>>Upcoming</option>
                                        <option value="ongoing" <?php echo ($edit_training && $edit_training->status == 'ongoing') ? 'selected' : ''; ?>>Ongoing</option>
                                        <option value="completed" <?php echo ($edit_training && $edit_training->status == 'completed') ? 'selected' : ''; ?>>Completed</option>
                                        <option value="cancelled" <?php echo ($edit_training && $edit_training->status == 'cancelled') ? 'selected' : ''; ?>>Cancelled</option>
                                    </select>
                                </div>

                                <!-- Training Image -->
                                <div class="form-group">
                                    <label>Training Image (Optional)</label>
                                    <input type="file" name="training_image" class="form-control-file" 
                                           accept="image/*" 
                                           onchange="previewImage(this)">
                                    <img id="image-preview" class="preview-image" style="display:none;">
                                </div>

                                <button type="submit" name="submit" class="btn btn-primary btn-block">
                                    <?php echo ($type == 'Edit' ? 'Update' : 'Add'); ?> Training
                                </button>
                            </form>
                        </div>
                    </div>
                </div>

                <!-- List Section -->
                <div class="col-lg-8">
                    <div class="card">
                        <div class="card-header">
                            <i class="fa fa-list"></i> Training List
                        </div>
                        <div class="card-body">
                            <!-- Filters and Search -->
                            <form method="GET" action="" class="mb-3">
                                <input type="hidden" name="action" value="<?php echo $page_name; ?>">
                                <div class="row">
                                    <div class="col-md-3">
                                        <select name="filter_type" class="form-control">
                                            <option value="">All Training Types</option>
                                            <option value="offline" <?php echo $filter_type == 'offline' ? 'selected' : ''; ?>>Offline</option>
                                            <option value="online" <?php echo $filter_type == 'online' ? 'selected' : ''; ?>>Online</option>
                                            <option value="hybrid" <?php echo $filter_type == 'hybrid' ? 'selected' : ''; ?>>Hybrid</option>
                                        </select>
                                    </div>
                                    <div class="col-md-3">
                                        <select name="filter_status" class="form-control">
                                            <option value="">All Statuses</option>
                                            <option value="upcoming" <?php echo $filter_status == 'upcoming' ? 'selected' : ''; ?>>Upcoming</option>
                                            <option value="ongoing" <?php echo $filter_status == 'ongoing' ? 'selected' : ''; ?>>Ongoing</option>
                                            <option value="completed" <?php echo $filter_status == 'completed' ? 'selected' : ''; ?>>Completed</option>
                                            <option value="cancelled" <?php echo $filter_status == 'cancelled' ? 'selected' : ''; ?>>Cancelled</option>
                                        </select>
                                    </div>
                                    <div class="col-md-3">
                                        <select name="filter_category" class="form-control">
                                            <option value="">All Categories</option>
                                            <?php foreach ($categories as $cat): ?>
                                                <option value="<?php echo htmlspecialchars($cat); ?>" 
                                                    <?php echo $filter_category == $cat ? 'selected' : ''; ?>>
                                                    <?php echo htmlspecialchars($cat); ?>
                                                </option>
                                            <?php endforeach; ?>
                                        </select>
                                    </div>
                                    <div class="col-md-3">
                                        <input type="text" name="search" class="form-control" 
                                               placeholder="Search trainings" 
                                               value="<?php echo htmlspecialchars($search_query ?? ''); ?>">
                                    </div>
                                </div>
                                <div class="row mt-2">
                                    <div class="col-12">
                                        <button type="submit" class="btn btn-primary btn-block">Search</button>
                                    </div>
                                </div>
                            </form>

                            <div class="table-responsive">
                                <table class="table table-hover">
                                    <thead class="thead-dark">
                                        <tr>
                                            <th>ID</th>
                                            <th>Title</th>
                                            <th>Date</th>
                                            <th>Location</th>
                                            <th>Type</th>
                                            <th>Status</th>
                                            <th>Fees</th>
                                             <th>Link</th>
                                             <th>Password</th>
                                            <th>Actions</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php foreach ($trainings as $training): ?>
                                            <tr>
                                                <td><?php echo $training->id; ?></td>
                                                <td class="truncate"><?php echo htmlspecialchars($training->title); ?></td>
                                                <td><?php echo date('d M Y', strtotime($training->date)); ?></td>
                                                <td class="truncate"><?php echo htmlspecialchars($training->location); ?></td>
                                                <td>
                                                    <span class="badge 
                                                    <?php 
                                                    switch($training->training_type) {
                                                        case 'online': echo 'badge-primary'; break;
                                                        case 'offline': echo 'badge-success'; break;
                                                        case 'hybrid': echo 'badge-warning'; break;
                                                        default: echo 'badge-secondary';
                                                    }
                                                    ?>">
                                                        <?php echo ucfirst($training->training_type); ?>
                                                    </span>
                                                </td>
                                                <td>
                                                    <span class="badge 
                                                    <?php 
                                                    switch($training->status) {
                                                        case 'upcoming': echo 'badge-info'; break;
                                                        case 'ongoing': echo 'badge-primary'; break;
                                                        case 'completed': echo 'badge-success'; break;
                                                        case 'cancelled': echo 'badge-danger'; break;
                                                        default: echo 'badge-secondary';
                                                    }
                                                    ?>">
                                                        <?php echo ucfirst($training->status); ?>
                                                    </span>
                                                </td>
                                                <td>₹<?php echo number_format($training->fees, 2); ?></td>
                                                <td><a href="../meetings/index.html" target="_blank">Join</a></td>
                                                <td><?php echo $md5Password ?></td>
                                                <td>
                                                    <a href="<?php echo $redirection_page; ?>&edit_id=<?php echo $training->id; ?>&type=Edit" class="btn btn-sm btn-warning">
                                                        <i class="fa fa-edit"></i>
                                                    </a>
                                                    <a href="<?php echo $redirection_page; ?>&delete_id=<?php echo $training->id; ?>&type=Delete" class="btn btn-sm btn-danger" onclick="return confirm('Are you sure you want to delete this training?');">
                                                        <i class="fa fa-trash"></i>
                                                    </a>
                                                </td>
                                            </tr>
                                        <?php endforeach; ?>
                                    </tbody>
                                </table>

                                <!-- Pagination -->
                                <nav>
                                    <ul class="pagination justify-content-center">
                                        <?php 
                                        // Build pagination URL with existing filters
                                        $base_url = $redirection_page;
                                        $filter_params = [];
                                        if ($filter_type) $filter_params[] = "filter_type=$filter_type";
                                        if ($filter_status) $filter_params[] = "filter_status=$filter_status";
                                        if ($filter_category) $filter_params[] = "filter_category=" . urlencode($filter_category);
                                        if ($search_query) $filter_params[] = "search=" . urlencode($search_query);
                                        $filter_url = $filter_params ? '&' . implode('&', $filter_params) : '';
                                        
                                        for ($page = 1; $page <= $total_pages; $page++): ?>
                                            <li class="page-item <?php echo ($page == $pageno) ? 'active' : ''; ?>">
                                                <a class="page-link" href="<?php echo $base_url; ?>&pageno=<?php echo $page; ?><?php echo $filter_url; ?>">
                                                    <?php echo $page; ?>
                                                </a>
                                            </li>
                                        <?php endfor; ?>
                                    </ul>
                                </nav>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- Debug Information  
<div class="container-fluid mt-3">
    <div class="card">
        <div class="card-header bg-warning">
            <i class="fa fa-bug"></i> Debug Information
        </div>
        <div class="card-body">
            <pre><?php 
            // Print out all POST data for debugging
            echo "POST Data:\n";
            print_r($_POST);
            
            echo "\nFILES Data:\n";
            print_r($_FILES);
            
            // Check database connection
            if (isset($dbconn)) {
                echo "\nDatabase Connection: Established\n";
                
                // Additional database connection details
                try {
                    $stmt = $dbconn->query("SELECT VERSION()");
                    $version = $stmt->fetchColumn();
                    echo "MySQL Version: $version\n";
                } catch (Exception $e) {
                    echo "Error checking MySQL version: " . $e->getMessage() . "\n";
                }
            } else {
                echo "\nDatabase Connection: NOT ESTABLISHED\n";
            }
            ?></pre>
        </div>
    </div>
</div>

-->

<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.2/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/flatpickr"></script>
<script>
$(document).ready(function() {
    // Initialize date pickers
    $(".datepicker").flatpickr({
        dateFormat: "Y-m-d",
        allowInput: true
    });

    // Initialize time picker
    $(".timepicker").flatpickr({
        enableTime: true,
        noCalendar: true,
        dateFormat: "H:i",
        time_24hr: true
    });

    // Image preview
    function previewImage(input) {
        var preview = document.getElementById('image-preview');
        if (input.files && input.files[0]) {
            var reader = new FileReader();
            reader.onload = function (e) {
                preview.src = e.target.result;
                preview.style.display = 'block';
            }
            reader.readAsDataURL(input.files[0]);
        } else {
            preview.style.display = 'none';
        }
    }
    window.previewImage = previewImage;
});
</script>
</body>
</html> 
← Back📥 Raw✏️ Edit🔒 Chmod
✨ File Manager Magic ✨