Server : LiteSpeed System : Linux us-phx-web1202.main-hosting.eu 4.18.0-553.84.1.lve.el8.x86_64 #1 SMP Tue Nov 25 18:33:03 UTC 2025 x86_64 User : u615232177 ( 615232177) PHP Version : 8.1.33 Disable Function : NONE Directory : /home/u615232177/domains/ellexsleevesapartments.com/public_html/admin1249/ |
<?php session_start();
$page_name = basename($_SERVER['PHP_SELF']);
include("headerstrict.php"); ?>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" rel="stylesheet">
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/summernote@0.8.18/dist/summernote.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/summernote@0.8.18/dist/summernote.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/perevoshchikov/summernote-grid@1.0.0/summernote-grid.min.js"></script>
<script>
$(document).ready(function() {
$('#summernote').summernote({
toolbar:[
['style', ['style']],
['font', ['bold', 'underline', 'clear']],
['color', ['color']],
['para', ['ul', 'ol', 'paragraph']],
['table', ['table']],
['insert', ['link', 'picture', 'video']],
['view', ['fullscreen', 'codeview', 'help']],
['insert', ['grid']]
],
grid: {
wrapper: "row",
columns: [
"col-md-12",
"col-md-6",
"col-md-4",
"col-md-3",
]
},
callbacks: {
onGridInsert: null
},
icons: {
grid: "glyphicon glyphicon-th"
}
});
});
</script>
<title><?php echo $company_name; ?>, Admin, Products</title>
<?php
if (isset($_GET['u'])){
$product_id = mysqli_real_escape_string($con,$_GET['u']);
$stmt = $con -> prepare('SELECT * FROM products WHERE product_id=?');
$stmt -> bind_param('s',$product_id);
$stmt -> execute();
$stmt -> store_result();
$stmt -> bind_result($product_id,$product_cat,$product_brand,$product_title,$product_price,$product_desc,$product_image,$product_keywords,$old_price,$new_tag,$home_products,$tags,$in_stock,$featured,$picture2,$picture3,$picture4,$picture5,$picture6);
$numrows = $stmt -> num_rows();
if($numrows > 0){
while ($stmt -> fetch()) {
$variant_id = $product_brand;
$variant_description = $tags;
}
}
}
else{echo "<meta http-equiv=\"refresh\" content=\"0; url=adminhome.php\">";exit();}
?>
<!-- ======= Breadcrumbs ======= -->
<section id="breadcrumbs" class="breadcrumbs">
<div class="container"> </div>
</section>
<!-- End Breadcrumbs -->
<!-- ======= Contact Section ======= -->
<section id="contact" class="contact inner-page">
<div class="container" data-aos="fade-up">
<div class="section-title">
<h2><?php echo $product_title; ?></h2>
<p></p>
</div>
<?php echo"<form action='";?><?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?><?php echo"?u=$product_id' method='post' class='php-email-form1'enctype='multipart/form-data'>";?>
<div class="row">
<?php
echo"
<div class='col-md-8'>
<div class='form-row'>
<div class='form-group col-md-12'>
<label>Product Name</label>
<input type='text' name='product_title' class='form-control' placeholder='Product Name' value='$product_title' required />
</div>
<div class='form-group col-md-12'>
<label>Brief Description </label>
<textarea id='summernote' name='product_desc' class='form-control' placeholder='Product Description'>$product_desc</textarea>
</div>
<div class='form-group col-md-12'><label>Category</label>";?>
<select name='product_cat' class="form-control" required>
<?php
$stmt = $con -> prepare('SELECT * FROM categories');
$stmt -> execute();
$stmt -> store_result();
$stmt -> bind_result($product_cat_select,$category_name_select,$ha,$ho);
$numrows = $stmt -> num_rows();
if($numrows > 0){
while ($stmt -> fetch()) {
echo"
<option value='$product_cat_select'"; if($product_cat == $product_cat_select){echo"selected";} echo">$category_name_select ($ho)</option>
";
}
}
else{echo"<option value=''>Please add a category first</option>";}
?>
</select>
<?php echo"</div>
<div class='form-group col-md-12'>
<label>Price</label>
<input type='number' name='product_price' class='form-control' placeholder='Current Price' value='$product_price'required />
</div>
<!--<div class='form-group col-md-12'>
<label>Variant Description (Default)</label>
<input type='text' name='variant_description' class='form-control' placeholder='Variant Description (Default)' value='$variant_description' />
</div>-->
</div>
</div>
<div class='col-md-4'>
</div>
<div class='form-group col-md-12'>
<div class='text-center'>
<button type='submit' name='update$product_id'>Update</button>
<button type='submit' name='delete$product_id'>Delete</button>
</div>
</div>
<!-- <div class='form-group col-md-12'> <hr>
<h3 style='color:;font-weight:900;'>ADD A VARIANT</h3>
<div class='form-row'>
<div class='form-group col-md-6'>
<label>Variant Description</label>
<input type='text' name='variant_description_new' class='form-control'/>
</div>
<div class='form-group col-md-6'>
<label>Variant Price</label>
<input type='text' name='variant_price_new' class='form-control'/>
</div>
</div>
</div>
<div class='form-group col-md-12'>
<div class='text-center'>
<button type='submit' name='save_variant'>Save variant</button>
</div>
</div>-->
"; ?>
<?php $count=0; $no="No";
$stmt_p = $con -> prepare('SELECT product_id,product_price,tags FROM products WHERE product_brand = ? AND old_price = ?');
$stmt_p -> bind_param('ss',$product_brand,$no);//variant_id
$stmt_p -> execute();
$stmt_p -> store_result();
$stmt_p -> bind_result($product_id_variant,$variant_price_db,$variant_description_db);
$numrows_p = $stmt_p -> num_rows();
if($numrows_p > 0){ ?>
<div class='form-group col-md-12'> <hr>
<h3 style='color:;font-weight:900;'>VARIANTS</h3>
<?php while ($stmt_p -> fetch()) { ?>
<form action="product_details.php?u=<?php echo $product_id ?>" method='post'>
<div class='form-row'>
<div class='form-group col-md-6'>
<label>Variant Description</label>
<input value='<?php echo $variant_description_db; ?>' type='text' name='variant_description_db' class='form-control'/>
</div>
<div class='form-group col-md-6'>
<label>Variant Price</label>
<input value='<?php echo $variant_price_db; ?>' type='text' name='variant_price_db' class='form-control'/>
</div>
</div>
<div class='form-group col-md-12'>
<div class='text-center'>
<button type='submit' name='update_variant<?php echo $product_id_variant; ?>'>Update</button>
<button type='submit' name='delete_variant<?php echo $product_id_variant; ?>'>Delete</button>
</div>
</div>
</form>
<?php
if (isset($_POST["update_variant$product_id_variant"])) {
$variant_description_db = mysqli_real_escape_string($con,$_POST['variant_description_db']);
$variant_price_db = mysqli_real_escape_string($con,$_POST['variant_price_db']);
$stmt11 = $con -> prepare('UPDATE products SET
product_price =?,
tags =? WHERE product_id =?');
$stmt11 -> bind_param('sss',
$variant_price_db,
$variant_description_db,
$product_id_variant);
$stmt11 -> execute();
//create a session to verify it's coming from here
$_SESSION["action"] = "true";
$message="Update was successfully done.";
echo "<meta http-equiv=\"refresh\" content=\"0; url=success.php?u=$page_name?u=$product_id&m=$message\">";
}
if (isset($_POST["delete_variant$product_id_variant"])) {
$stmt_d = $con -> prepare('DELETE FROM products WHERE product_id = ?');
$stmt_d -> bind_param('i', $product_id_variant);
$stmt_d -> execute();
$_SESSION["action"] = "true";
$message="Variant deleted.";
echo "<meta http-equiv=\"refresh\" content=\"0; url=success.php?u=$page_name?u=$product_id&m=$message\">";
}
?>
<?php } ?>
</div>
<?php } ?>
<?php if (isset($_POST["save_variant"])) {
$variant_description_new = mysqli_real_escape_string($con,$_POST['variant_description_new']);
$variant_price_new = mysqli_real_escape_string($con,$_POST['variant_price_new']);
$db_id=0; $no="No";
$stmt = $con -> prepare('INSERT INTO products VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)');
$stmt -> bind_param('issssssssssssssssss', $db_id,$product_cat,$product_brand,$product_title,$variant_price_new,$product_desc,$product_image,$product_keywords,$no,$new_tag,$home_products,$variant_description_new,$in_stock,$featured,$picture2,$picture3,$picture4,$picture5,$picture6);
$stmt -> execute();
//create a session to verify it's coming from here
$_SESSION["action"] = "true";
$message="Variant successfully added.";
echo "<meta http-equiv=\"refresh\" content=\"0; url=success.php?u=$page_name?u=$product_id&m=$message\">";
}
if (isset($_POST["update$product_id"])) {
$product_cat = mysqli_real_escape_string($con,$_POST['product_cat']);
$product_title = mysqli_real_escape_string($con,$_POST['product_title']);
$product_price = mysqli_real_escape_string($con,$_POST['product_price']);
$product_desc = mysqli_real_escape_string($con,$_POST['product_desc']);
$product_keywords="$product_title $product_desc";
$featured="";
$stmt1 = $con -> prepare('UPDATE products SET
product_cat =?,
product_title =?,
product_price =?,
product_desc =?,
product_image=?,
product_keywords =?,
new=?,
home_products=?,
tags=?,
in_stock=?,
picture2 =?,
picture3 =?,
picture4 =?,
picture5 =?,
picture6 =? WHERE product_id =?');
$stmt1 -> bind_param('ssssssssssssssss',
$product_cat,
$product_title,
$product_price,
$product_desc,
$product_image,
$product_keywords,
$new_tag,
$home_products,
$default_variant_description,
$in_stock,
$picture2,
$picture3,
$picture4,
$picture5,
$picture6,
$product_id);
$stmt1 -> execute();
//a second update statement which is virtually the same except
//product_price and tags are ommited
//it will be 'WHERE product_brand = variant_id AND old_price = no'
//2:02 AM 22 SEPT 2024 to be continued.
$stmt2 = $con -> prepare('UPDATE products SET
product_cat =?,
product_title =?,
product_desc =?,
product_image=?,
product_keywords =?,
new=?,
home_products=?,
in_stock=?,
picture2 =?,
picture3 =?,
picture4 =?,
picture5 =?,
picture6 =? WHERE product_brand =?');
$stmt2 -> bind_param('ssssssssssssss',
$product_cat,
$product_title,
$product_desc,
$product_image,
$product_keywords,
$new_tag,
$home_products,
$in_stock,
$picture2,
$picture3,
$picture4,
$picture5,
$picture6,
$variant_id);
$stmt2 -> execute();
//create a session to verify it's coming from here
$_SESSION["action"] = "true";
$message="Update was successfully done.";
echo "<meta http-equiv=\"refresh\" content=\"0; url=success.php?u=products.php&m=$message\">";
}
if (isset($_POST["delete$product_id"])) {
$stmt = $con -> prepare('DELETE FROM products WHERE product_id = ?');
$stmt -> bind_param('s', $product_id);
$stmt -> execute();
//unlink("../site_img/products/$product_image");
if($picture2 !==""){unlink("../site_img/products/$picture2");}
if($picture3 !==""){unlink("../site_img/products/$picture3");}
if($picture4 !==""){unlink("../site_img/products/$picture4");}
if($picture5 !==""){unlink("../site_img/products/$picture5");}
if($picture6 !==""){unlink("../site_img/products/$picture6");}
//delete variants too
$stmtz = $con -> prepare('DELETE FROM products WHERE product_brand = ?');
$stmtz -> bind_param('s', $variant_id);
$stmtz -> execute();
//create a session to verify it's coming from here
$_SESSION["action"] = "true";
$message="Product successfully deleted.";
echo "<meta http-equiv=\"refresh\" content=\"0; url=success.php?u=products.php&m=$message\">";
}
?>
</div><!-- end row -->
</form>
<br/></br>
</div>
</section><!-- End Contact Section -->
<!-- ======= Footer ======= -->
<footer id="footer" style='background:;'>
<div class="container footer-bottom clearfix">
<div class="copyright">
© Copyright <?php $odun=date('Y'); echo "$odun"; ?> <strong><span><?php echo $company_name; ?></span></strong>. All Rights Reserved
</div>
<div class="credits">
</div>
</div>
</footer><!-- End Footer -->
<a href="#" class="back-to-top"><i class="ri-arrow-up-line"></i></a>
<div id="preloader"style='background:<?php echo $t_cr; ?>;'></div>
<!-- Vendor JS Files -->
<script src="assets/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="assets/vendor/jquery.easing/jquery.easing.min.js"></script>
<script src="assets/vendor/php-email-form/validate.js"></script>
<script src="assets/vendor/waypoints/jquery.waypoints.min.js"></script>
<script src="assets/vendor/isotope-layout/isotope.pkgd.min.js"></script>
<script src="assets/vendor/venobox/venobox.min.js"></script>
<script src="assets/vendor/owl.carousel/owl.carousel.min.js"></script>
<script src="assets/vendor/aos/aos.js"></script>
<!-- Template Main JS File -->
<script src="assets/js/main.js"></script>
</body>
</html>