🚀 Hostinger Optimized
🖥️ Server: LiteSpeed
💻 System: Linux in-mum-web1643.main-hosting.eu 5.14.0-687.46.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Sep 11 09:03:19 EDT 2026 x86_64
👤 User: u621169360 (621169360)
🐘 PHP: 8.2.33
🚫 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
$

📄 fetch_user_trainings.php

📁 Path: /home/u621169360/domains/agriexpertt.com/public_html/mobile/Flutter/fetch_user_trainings.php
📊 Size: 1.99 KB
🔒 Perm: 0644
📝 MIME: text/x-php
<?php
// Enable error reporting for debugging
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

// Enable CORS headers
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: GET");
header("Access-Control-Allow-Headers: Content-Type");
header("Content-Type: application/json; charset=UTF-8");

// Include database connection
require_once 'db.php';

// Check if user_id is provided
if (!isset($_GET['user_id']) || empty($_GET['user_id'])) {
    http_response_code(400);
    echo json_encode([
        'status' => 'error',
        'message' => 'User ID is required'
    ]);
    exit;
}

try {
    // Sanitize user ID
    $userId = intval($_GET['user_id']);

    // Prepare SQL to fetch user's trainings with full training details
    $stmt = $pdo->prepare("
        SELECT 
            tp.id AS registration_id,
            t.id AS training_id,
            t.title,
            t.date,
            t.time,
            t.location,
            t.description,
            t.fees,
            t.trainer_name,
            t.training_type,
            t.difficulty_level,
            t.category,
            t.training_image,
            tp.registration_date,
            tp.payment_status
        FROM 
            training_participants tp
        JOIN 
            trainings t ON tp.training_id = t.id
        WHERE 
            tp.user_id = :user_id
        ORDER BY 
            t.date DESC
    ");

    $stmt->execute(['user_id' => $userId]);
    $trainings = $stmt->fetchAll(PDO::FETCH_ASSOC);

    // Prepare response
    $response = [
        'status' => 'success',
        'message' => $trainings ? 'Trainings retrieved successfully' : 'No trainings found',
        'total_trainings' => count($trainings),
        'trainings' => $trainings
    ];

    echo json_encode($response);
} catch (Exception $e) {
    http_response_code(500);
    echo json_encode([
        'status' => 'error',
        'message' => 'Error fetching trainings: ' . $e->getMessage()
    ]);
}
?> 
← Back📥 Raw✏️ Edit🔒 Chmod
✨ File Manager Magic ✨