<?php
// Include your database connection code here (e.g., dbconn.php)
require_once 'includes/dbconn.php';

// Check if the form is submitted
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    // Retrieve form data
    $category_name = $_POST["category_name"];
    $created_at = $_POST["created_at"];

    // Get the current created date
    $created_at = date('Y-m-d H:i:s');

    // Perform database insertion
    $sql = "INSERT INTO exp_category (category_name, created_at) 
            VALUES ('$category_name', '$created_at')";

    if ($conn->query($sql) === TRUE) {
        // Redirect to the same page after successful submission
        header("Location: ".$_SERVER['HTTP_REFERER']);
        exit();
    } else {
        // Handle the error, you might want to display an error message or log the error
        echo "Error: " . $sql . "<br>" . $conn->error;
    }
}

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

