Trying to submit a form for a product addition
I try to submit a form it turns, but no addition to the databases, tried it several times but nothing
But when I change and instead put the form as a external php file on its own it works….and I don’t really see what the problem is with this page
The php code here is the select from the tables so on this same page I want to print and submit products but when I submit it no product added don’t really know if did something wrong on this page specifically
</style>
<!-- <a href="add.php" style="padding-left: 88%;"><button class="view" style="background-color: lightseagreen;">+ AddNew</button></a> -->
<button class="view"
onclick="togglePopup()" style="width: 160px; background-color: lightseagreen;">+ AddNew</button>
<a href="add11.php">+ AddNew</a>
<div class="report-container">
<div class="report-header">
<h1 class="recent-Articles">Products Info</h1>
<button class="view"><?=count($productss)?> Products</button>
<button class="view">Products List</button>
<!-- <div class="view" width="10px">Products List</div> -->
</div>
<div class="report-body">
<div class="report-topic-heading">
<h3 class="t-op" style="margin-right: 60px;">Product Image</h3>
<h3 class="t-op" style="margin-right: 60px; margin-left: 30px;">Category</h3>
<h3 class="t-op" style="margin-right: 70px; margin-left: 40px;">Name</h3>
<h3 class="t-op" style="margin-right: 60px; margin-left: 30px;">Price</h3>
<h3 class="t-op" style="margin-right: 60px; margin-left: 30px;" >Quantity</h3>
<h3 class="t-op" style="margin-right: 60px; margin-left: 30px;">Actions</h3>
<hr>
</div>
<div class="items">
<?php foreach($productss as $item){
$sql = "SELECT * FROM product_category WHERE category_id = :id";
$statment = $db->prepare($sql);
$statment->bindvalue(':id', $item["category_id"], PDO::PARAM_INT);
$statment->execute();
$product_categorys = $statment->fetchAll(PDO::FETCH_ASSOC);
$product_category=$product_categorys[0];
$item["category_names"]=$product_categorys[0]["category_name"];
?>
<div class="item1">
<h3 class="t-op-nextlvl" style="margin-right: 60px;"><img src="../upload/<?=$item["product_image"]?>" width="80px"></h3>
<h3 class="t-op-nextlvl" style="margin-right: 60px; margin-left: 30px;"><?=$item["category_names"]?></h3>
<h3 class="t-op-nextlvl" style="margin-right: 60px; margin-left: 30px;"><?=$item["name"]?></h3>
<h3 class="t-op-nextlvl" style="margin-right: 60px; margin-left: 30px;"><?=$item["price"]?></h3>
<h3 class="t-op-nextlvl" style="margin-right: 60px; margin-left: 30px;"><?=$item["qty"]?></h3>
<hr>
<form method="POST" action="" style="display: flex; flex-direction: row;">
<h3 class="t-op-nextlvl" style="margin-right:46px;"><a href="Delete.php?id=<?=$item['product_id']?>"><img src="../Icons/delete.png" width="30px" alt=""></a></h3>
<input type="hidden" value="<?=$item['product_id']?>" name="id" id="">
<button name="submitbtn" type="submit" style="border: none;"><img src="../Icons/edit.png" alt="edit" width="35px"></button>
</div>
<?php
}
?>
</div>
</div>
</div>
<div id="popupOverlay" class="overlay-container" style="padding-bottom: 30px">
<div class="popup-box" style="width: 570px;">
<h2 style="color: green;">Add A Product</h2>
<form method="post" action="" enctype="multipart/form-data" style="padding-top: 20px; padding-left: 40px;">
<div id="feedback-form">
<h2 class="header">New Product</h2>
<div>
<section>
<div class="select-containers">
<select class="select-box" name="category_id" id="">
<option value="" selected disabled>
Choose The Product Category
</option>
<?php
foreach($product_categoryss as $item1){
?>
<option value="<?=$item1["category_id"]?>"><?=$item1["category_name"]?></option>
</div>
<?php
}
?>
<input type="text" name="name" placeholder="Product Name" required></input>
<input type="number" name="price" placeholder="price" required></input>
<input type="number" name="qty" placeholder="Quantity" required></input>
<input type="text" name="description" placeholder="description" required></input>
<input type="file" name="product_image" placeholder="Main Image" required></input>
<input type="file" name="product_image1" placeholder="Image1" required></input>
<input type="file" name="product_image2" placeholder="Image2" required></input>
<input type="file" name="product_image3" placeholder="Image3" required></input>
<input type="file" name="product_image4" placeholder="Image4" required></input>
<button type="submit">Submit</button>
</section>
<!-- <center>
<input type="reset" class="btn btn-dark" value="Cancel">
<input type="submit" class="btn btn-primary" name="envoyer" value="Add">
</center> -->
</form>
<button class="btn-close-popup" onclick="togglePopup()">Close</button>
</div>