36716-vm/index.php
2025-12-07 05:02:18 +00:00

235 lines
6.8 KiB
PHP

<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
ini_set('log_errors', 1);
ini_set('error_log', __DIR__ . '/debug.log');
session_start();
require_once 'db/config.php';
// Fetch settings and redirect if in single coach mode
$settings_stmt = db()->query('SELECT setting_key, setting_value FROM settings');
$settings = $settings_stmt->fetchAll(PDO::FETCH_KEY_PAIR);
$coach_mode = $settings['coach_mode'] ?? 'multi';
$single_coach_id = $settings['single_coach_id'] ?? null;
if ($coach_mode === 'single' && !empty($single_coach_id)) {
header('Location: profile.php?id=' . $single_coach_id);
exit;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Coaching Platform</title>
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
</head>
<body class="bg-gray-50">
<!-- Header -->
<header class="bg-white shadow">
<nav class="container mx-auto px-6 py-3">
<div class="flex justify-between items-center">
<a href="index.php" class="text-2xl font-bold text-gray-800">Coaching Platform</a>
<div class="flex space-x-4">
<a href="index.php" class="text-gray-600 hover:text-blue-500">Home</a>
<?php if ($coach_mode === 'multi'): ?>
<a href="coaches.php" class="text-gray-600 hover:text-blue-500">Coaches</a>
<?php endif; ?>
<?php if (isset($_SESSION['user_id'])): ?>
<a href="dashboard.php" class="text-gray-600 hover:text-blue-500">Dashboard</a>
<a href="messages.php" class="text-gray-600 hover:text-blue-500">Messages</a>
<a href="logout.php" class="text-gray-600 hover:text-blue-500">Logout</a>
<?php else: ?>
<a href="login.php" class="text-gray-600 hover:text-blue-500">Login</a>
<a href="register-client.php" class="text-gray-600 hover:text-blue-500">Sign Up</a>
<a href="register-coach.php" class="text-gray-600 hover:text-blue-500">Become a Coach</a>
<?php endif; ?>
</div>
</div>
</nav>
</header>
<!-- Hero Section -->
<main class="container mx-auto px-6 py-12">
<section class="text-center">
<h1 class="text-5xl font-bold text-gray-800 mb-4">Unlock Your Potential</h1>
<p class="text-xl text-gray-600 mb-8">Find the perfect coach to help you achieve your goals.</p>
<a href="#featured-coaches" class="bg-blue-600 text-white font-bold py-3 px-8 rounded-lg hover:bg-blue-700 text-lg scroll-smooth">Find Your Coach</a>
</section>
<!-- Featured Coaches Section -->
<section id="featured-coaches" class="py-12">
<h2 class="text-3xl font-bold text-center text-gray-800 mb-8">Featured Coaches</h2>
<div class="grid md:grid-cols-3 gap-8">
<?php
require_once 'db/config.php';
try {
$pdo = db();
$stmt = $pdo->query("SELECT * FROM coaches ORDER BY created_at DESC LIMIT 3");
$coaches = $stmt->fetchAll();
foreach ($coaches as $coach) {
echo '<div class="bg-white rounded-lg shadow-md p-6 text-center">';
echo '<img class="w-32 h-32 rounded-full mx-auto mb-4" src="' . htmlspecialchars($coach['photo_url'] ?: 'https://i.pravatar.cc/150?img=' . $coach['id']) . '" alt="' . htmlspecialchars($coach['name']) . '">';
echo '<h3 class="text-xl font-bold text-gray-800">' . htmlspecialchars($coach['name']) . '</h3>';
echo '<p class="text-gray-600 mb-4">' . htmlspecialchars($coach['specialty']) . '</p>';
echo '<a href="profile.php?id=' . $coach['id'] . '" class="bg-blue-100 text-blue-600 font-semibold py-2 px-4 rounded-lg hover:bg-blue-200">View Profile</a>';
echo '</div>';
}
} catch (PDOException $e) {
echo '<p class="text-center text-red-500">Error fetching coaches: ' . $e->getMessage() . '</p>';
}
?>
</div>
</section>
<!-- How It Works Section -->
<section class="py-12 bg-white rounded-lg shadow-md mt-12">
<h2 class="text-3xl font-bold text-center text-gray-800 mb-8">How It Works</h2>
<div class="grid md:grid-cols-3 gap-8 text-center">
<div>
<div class="text-4xl font-bold text-blue-600 mb-2">1</div>
<h3 class="text-xl font-bold text-gray-800 mb-2">Browse Coaches</h3>
<p class="text-gray-600">Find the perfect coach from our curated list of experts.</p>
</div>
<div>
<div class="text-4xl font-bold text-blue-600 mb-2">2</div>
<h3 class="text-xl font-bold text-gray-800 mb-2">Book a Session</h3>
<p class="text-gray-600">Schedule a session that fits your time and needs.</p>
</div>
<div>
<div class="text-4xl font-bold text-blue-600 mb-2">3</div>
<h3 class="text-xl font-bold text-gray-800 mb-2">Start Learning</h3>
<p class="text-gray-600">Begin your journey of growth with personalized coaching.</p>
</div>
</div>
</section>
</main>
<!-- Footer -->
<footer class="bg-gray-800 text-white py-6 mt-12">
<div class="container mx-auto px-6 text-center">
<p>&copy; <?php echo date("Y"); ?> CoachConnect. All rights reserved.</p>
</div>
</footer>
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
</body>
</html>