<?php
// Include the database configuration file
include 'config.php';

// Check if form is submitted
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    // Get form data
    $name = $_POST['name'];
    $studentId = $_POST['studentId'];
    $phone = $_POST['phone'];

    // Prepare and execute SQL query to insert user details into cart table
    $sql = "INSERT INTO cart (name, student_id, phone) VALUES ('$name', '$studentId', '$phone')";
    
    if ($conn->query($sql) === TRUE) {
        echo "User details stored successfully in the cart table.";
    } else {
        echo "Error: " . $sql . "<br>" . $conn->error;
    }
    
    // Close the database connection
    $conn->close();
}
?>
