<?php include("includes/db.php"); include("includes/auth.php");

if(isset($_POST['upload'])){
  $img="uploads/".time().$_FILES['image']['name'];
  move_uploaded_file($_FILES['image']['tmp_name'],$img);
  $conn->query("INSERT INTO banners(image) VALUES('$img')");
}

$res=$conn->query("SELECT * FROM banners");
?>
<h2>Banners</h2>
<form method="post" enctype="multipart/form-data">
<input type="file" name="image">
<button name="upload">Upload</button>
</form>

<?php while($b=$res->fetch_assoc()): ?>
<img src="<?= $b['image'] ?>" width="200">
<a href="?del=<?= $b['id'] ?>">Delete</a><br>
<?php endwhile; ?>
