<?php
// Assuming you have a database connection script (e.g., shikanisha.kts.php)
require('shikanisha.kts.php');

// Fetch form data
$ageGroup = $_POST['age_status'];
$cost = $_POST['amount'];
$numberOfPersons = $_POST['count'];
$totalCost = $_POST['totamount'];
$date = date('Y-m-d H:i:s');

// Check connection
if ($conn->connect_error) {
    $response = array("success" => false, "message" => "Database connection failed");
} else {
    // Perform the database insertion (replace with your actual SQL query)
    $sql = "INSERT INTO `swimo` (`age_group`, `cost`, `no_persons`, `total_cost`, `date_column`) VALUES ('$ageGroup', $cost, $numberOfPersons, $totalCost, '$date')";

    if ($conn->query($sql) === TRUE) {
        $response = array("success" => true, "message" => "Session started successfully");
    } else {
        $response = array("success" => false, "message" => "Error starting session");
    }

    // Close the database connection
    $conn->close();
}

// Send JSON response back to the JavaScript
header('Content-Type: application/json');
echo json_encode($response);
?>
