Admin Page
Admin Page
php
@include 'config.php';
if(isset($_POST['add_product'])){
$product_name = $_POST['product_name'];
$product_price = $_POST['product_price'];
$product_image = $_FILES['product_image']['name'];
$product_image_tmp_name = $_FILES['product_image']['tmp_name'];
$product_image_folder = 'uploaded_img/'.$product_image;
};
if(isset($_GET['delete'])){
$id = $_GET['delete'];
mysqli_query($conn, "DELETE FROM products WHERE id = $id");
header('location:admin_page.php');
};
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>admin page</title>
</head>
<body>
<?php
if(isset($message)){
foreach($message as $message){
echo '<span class="message">'.$message.'</span>';
}
}
?>
<div class="container">
<div class="admin-product-form-container">
</div>
<?php
?>
<div class="product-display">
<table class="product-display-table">
<thead>
<tr>
<th>product image</th>
<th>product name</th>
<th>product price</th>
<th>action</th>
</tr>
</thead>
<?php while($row = mysqli_fetch_assoc($select)){ ?>
<tr>
<td><img src="uploaded_img/<?php echo $row['image']; ?>" height="100"
alt=""></td>
<td><?php echo $row['name']; ?></td>
<td>$<?php echo $row['price']; ?>/-</td>
<td>
<a href="admin_update.php?edit=<?php echo $row['id']; ?>"
class="btn"> <i class="fas fa-edit"></i> edit </a>
<a href="admin_page.php?delete=<?php echo $row['id']; ?>"
class="btn"> <i class="fas fa-trash"></i> delete </a>
</td>
</tr>
<?php } ?>
</table>
</div>
</div>
</body>
</html>