<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Add Subject Result</title>
    <link rel="stylesheet" href="styles.css"> <!-- Link your CSS file here -->
</head>
<body>
    <div class="message">
        <?php
        include('db_connection.php'); // Include your database connection file

        if ($_SERVER["REQUEST_METHOD"] == "POST") {
            $subject_name = $_POST['subject_name'];

            // Insert into subjects table
            $insert_query = "INSERT INTO subject (subject_name) VALUES (?)";
            $stmt = $conn->prepare($insert_query);
            $stmt->bind_param("s", $subject_name);

            if ($stmt->execute()) {
                echo "Subject added successfully!";
            } else {
                echo "Error: " . $conn->error;
            }

            $stmt->close();
            $conn->close();
        }
        ?>
    </div>

    <div class="back-button">
        <a href="add_subject.php" class="button">Go Back to Add Subject</a>
    </div>
</body>
</html>
