34352-vm/create_team.php
Flatlogic Bot 6424a2c0f6 1.3
2025-09-24 19:44:13 +00:00

26 lines
681 B
PHP

<?php
require_once __DIR__ . '/db/config.php';
session_start();
// Assuming a logged-in coach with ID 1
$coach_id = 1;
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$team_name = trim($_POST['team_name']);
if (!empty($team_name)) {
try {
$pdo = db();
$stmt = $pdo->prepare("INSERT INTO teams (name, coach_id) VALUES (?, ?)");
$stmt->execute([$team_name, $coach_id]);
$_SESSION['success_message'] = 'Team created successfully!';
} catch (PDOException $e) {
$_SESSION['error_message'] = 'Error creating team: ' . $e->getMessage();
}
}
header('Location: coach.php');
exit;
}
?>