<?php
include 'db.php';

$title = $_POST['title'];
$name = $_POST['name'];

$target_dir = "uploads/";
$image_name = basename($_FILES["banner"]["name"]);
$target_file = $target_dir . $image_name;

move_uploaded_file($_FILES["banner"]["tmp_name"], $target_file);

$sql = "INSERT INTO banners (title, name, image) VALUES ('$title', '$name', '$image_name')";

if ($conn->query($sql)) {
    echo "Banner added successfully!";
} else {
    echo "Error: " . $conn->error;
}

header("Location: index.php");
?>
