<?php include '_head.php'; if($_SERVER['REQUEST_METHOD']=='POST'){ $name=mysqli_real_escape_string($conn,$_POST['name']); $ex=isset($_POST['exclusive'])?1:0; $logo=upload_file('logo','uploads/banners'); mysqli_query($conn,"INSERT INTO brands(name,logo,exclusive) VALUES('$name','$logo',$ex)"); } if(isset($_GET['delete'])){mysqli_query($conn,"DELETE FROM brands WHERE id=".(int)$_GET['delete']);} $rs=mysqli_query($conn,"SELECT * FROM brands ORDER BY id DESC"); ?><h1>Brands</h1><form class="admin-card" method="post" enctype="multipart/form-data"><input name="name" placeholder="Brand name" required><label><input type="checkbox" name="exclusive"> Exclusive</label><input type="file" name="logo"><button class="primary-btn">Add</button></form><table class="table"><tr><th>ID</th><th>Name</th><th></th></tr><?php while($r=mysqli_fetch_assoc($rs)): ?><tr><td><?php echo $r['id']; ?></td><td><?php echo e($r['name']); ?></td><td><a href="?delete=<?php echo $r['id']; ?>">Delete</a></td></tr><?php endwhile; ?></table><?php include '_foot.php'; ?>
