<?php include 'includes/header.php'; ?>
<?php include 'includes/sidebar.php'; ?>
<?php require 'includes/db_connect.php'; ?>

<h3 class="text-orange fw-bold">Add New Association</h3>

<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $street_name = $_POST['street_name'];
    $location = $_POST['location'];
    $description = $_POST['description'];
    
    $sql = "INSERT INTO association (street_name, location, description) 
            VALUES ('$street_name', '$location', '$description')";

    if ($conn->query($sql)) {
        echo "<div class='alert alert-success'>Street added successfully.</div>";
    } else {
        echo "<div class='alert alert-danger'>Error: " . $conn->error . "</div>";
    }
}
?>

<div class="card shadow mt-4">
    <div class="card-body">
        <form method="POST">
            <div class="mb-3">
                <label class="form-label">Association Name</label>
                <input type="text" name="street_name" class="form-control" required>
            </div>

            <div class="mb-3">
                <label class="form-label">Location / Area</label>
                <input type="text" name="location" class="form-control" required>
            </div>

            <div class="mb-3">
                <label class="form-label">Description (optional)</label>
                <textarea name="description" class="form-control" rows="4"></textarea>
            </div>

            <button type="submit" class="btn btn-orange">Save Street</button>
        </form>
    </div>
</div>

<?php include 'includes/footer.php'; ?>
