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/marisgoldunisexboutique.com/public_html/admin0564/ |
<?php session_start();
$page_name = basename($_SERVER['PHP_SELF']);
include("headerstrict.php"); ?>
<title><?php echo $company_name; ?>, Admin, Homepage Boxes</title>
<?php
if (isset($_POST['add_homepage_picture'])) {
$heading = mysqli_real_escape_string($con,$_POST['heading']);
$link_text = mysqli_real_escape_string($con,$_POST['link_text']);
$link = mysqli_real_escape_string($con,$_POST['link']);
if( ($_FILES["fileField"]["type"]=="") == false ){
$random_id = substr(md5(rand()), 0, 20);
$extension = pathinfo($_FILES["fileField"]["name"], PATHINFO_EXTENSION);
move_uploaded_file( $_FILES['fileField']['tmp_name'], "assets/img/home_boxes/$random_id.$extension");
$picture ="$random_id.$extension";
$db_id=0;
$stmt = $con -> prepare('INSERT INTO boxes VALUES (?,?,?,?,?)');
$stmt -> bind_param('issss', $db_id,$heading,$link,$link_text,$picture);
$stmt -> execute();
//create a session to verify it's coming from here
$_SESSION["action"] = "true";
$message="Item successfully added.";
echo "<meta http-equiv=\"refresh\" content=\"0; url=success.php?u=$page_name&m=$message\">";
}
else{
$_SESSION["action"] = "true";
$message="No picture found to upload.";
echo "<meta http-equiv=\"refresh\" content=\"0; url=failure.php?u=$page_name&m=$message\">";
}
}
?>
<!-- ======= 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>Home Boxes</h2>
<p>Add an item</p>
</div>
<div class="row">
<div class="col-lg-6 mt-5 mt-lg-0 d-flex align-items-stretch">
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post" class="php-email-form1" enctype='multipart/form-data'>
<div class='validate'><?php echo $error; ?></div>
<div class="form-row">
<div class="form-group col-md-6">
<input type="text" name="heading" class="form-control" placeholder="Heading" required />
</div>
<div class="form-group col-md-6">
<input type="text" name="link_text" class="form-control" placeholder="Link Text" required />
</div>
<div class="form-group col-md-12">
<input type="text" name="link" class="form-control" placeholder="Link" required />
</div>
</div>
<div class="form-row">
<div class="form-group col-md-12">
<input type='file' name='fileField' class="form-control" required />
</div>
</div>
<div class="text-center">
<button type="submit" name='add_homepage_picture'>Save</button>
</div>
</form>
</div>
<div class="col-lg-6 d-flex align-items-stretch">
</div>
</div><!-- end row
<br/></br>-->
<div class="section-title">
<h2>Uploaded Boxes</h2>
</div>
<div class='row'>
<?php
$stmt = $con -> prepare('SELECT * FROM boxes');
$stmt -> execute();
$stmt -> store_result();
$stmt -> bind_result($id,$heading,$link,$link_text,$picture);
$numrows = $stmt -> num_rows();
if($numrows > 0){
while ($stmt -> fetch()) {
if($id == 1 OR $id == 2){$col = 6; $w = "Main Landing Page";}
else{$col = 4;}
if($id == 3 OR $id == 4 OR $id == 5){$w = "Mens Landing Page";}
if($id == 6 OR $id == 7 OR $id == 8){$w = "Womens Landing Page";}
echo"
<div class='col-md-$col'> <h3>$w</h3>
<form action='";?><?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?><?php echo"' method='post'class='php-email-form1'enctype='multipart/form-data'>
<div class='form-row'>
<div class='form-group col-md-12'>
<label for=''>Heading</label>
<input type='text' name='heading' class='form-control' placeholder='Heading' value='$heading' required />
</div>
<div class='form-group col-md-12'>
<label>Link Text</label>
<input type='text' name='link_text' class='form-control' placeholder='Link Text' value='$link_text' required />
</div>
<div class='form-group col-md-12'>
<label>Link</label>
<input type='text' name='link' class='form-control' placeholder='Link' value='$link'required />
</div>
</div>
<div class='form-row'>
<div class='form-group col-md-12'>
<label>Image</label>
<img style='width:100%;border-radius:5px;'src='assets/img/home_boxes/$picture' class='img-fluid' alt=''>
<input type='file' name='fileField' class='form-control'/>
</div>
</div>
<div class='text-center'>
<button type='submit' name='update$id'>Update</button>
</div>
</form> <br>
</div>
";
if (isset($_POST["update$id"])) {
$heading = mysqli_real_escape_string($con,$_POST['heading']);
$link_text = mysqli_real_escape_string($con,$_POST['link_text']);
$link = mysqli_real_escape_string($con,$_POST['link']);
if( ($_FILES["fileField"]["type"]=="") == false ){
unlink("assets/img/home_boxes/$picture");
$random_id = substr(md5(rand()), 0, 20);
$extension = pathinfo($_FILES["fileField"]["name"], PATHINFO_EXTENSION);
move_uploaded_file( $_FILES['fileField']['tmp_name'], "assets/img/home_boxes/$random_id.$extension");
$picture ="$random_id.$extension";
}
$stmt = $con -> prepare('UPDATE boxes SET heading = ?,link = ?,link_text=?,picture=? WHERE id = ?');
$stmt -> bind_param('ssssi', $heading,$link,$link_text,$picture,$id);
$stmt -> 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&m=$message\">";
}
if (isset($_POST["delete$id"])) {
$stmt = $con -> prepare('DELETE FROM boxes WHERE id = ?');
$stmt -> bind_param('i', $id);
$stmt -> execute();
unlink("assets/img/home_boxes/$picture");
//create a session to verify it's coming from here
$_SESSION["action"] = "true";
$message="Item successfully deleted.";
echo "<meta http-equiv=\"refresh\" content=\"0; url=success.php?u=$page_name&m=$message\">";
}
}
}
?>
</div>
</div>
</section><!-- End Contact Section -->
<?php include("footer.php"); ?>