Mini Kabibi Habibi

Current Path : C:/xampp/htdocs/cid/system/
Upload File :
Current File : C:/xampp/htdocs/cid/system/add_new_schedule.php

<?php
// Database connection
@include 'include/config.php';

session_start();
@include 'include/config.php';

if (!isset($_SESSION['username_school'])) {
    header('Location: login.php');
    exit();
}

$username = $_SESSION['username_school']; // Get the username from the session

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $name = $_POST['fullname'];
    $activities = $_POST['activities'];
    $date = $_POST['date'];

    // Updated SQL — no need to check for "Others" logic anymore
    $sql = "INSERT INTO schedule (name, username, activities, date) 
            VALUES (?, ?, ?, ?)";

    if ($stmt = $conn->prepare($sql)) {
        $stmt->bind_param("ssss", $name, $username, $activities, $date);

        if ($stmt->execute()) {
            header('Location: user_index.php');
            exit();
        } else {
            echo "Error: " . $stmt->error;
        }

        $stmt->close();
    } else {
        echo "Error preparing the SQL query.";
    }
}
?>