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/public_html/admin5352/ |
<?php session_start();
$page_name = basename($_SERVER['PHP_SELF']);
include("headerstrict.php"); ?>
<title><?php echo $company_name; ?>, Admin, Delivery Zones</title>
<?php
if (isset($_POST['add_delivery_zone'])) {
$fee = mysqli_real_escape_string($con,$_POST['fee']);
$zone = mysqli_real_escape_string($con,$_POST['zone']);
$locations = mysqli_real_escape_string($con,$_POST['locations']);
$display = mysqli_real_escape_string($con,$_POST['display']);
$db_id=0;
$stmt = $con -> prepare('INSERT INTO delivery_zones VALUES (?,?,?,?,?)');
$stmt -> bind_param('issss', $db_id,$fee,$zone,$locations,$display);
$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\">";
}
?>
<!-- ======= 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>Delivery Zones</h2>
<p>Add a zone</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="number" name="fee" class="form-control" placeholder="Fee" required />
</div>
<div class="form-group col-md-6">
<input type="text" name="zone" class="form-control" placeholder="Zone" required />
</div>
<div class="form-group col-md-12">
<textarea name="locations" cols="5" rows="2" class="form-control" placeholder="Locations" required></textarea>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-12">
<select name='display' class="form-control" required>
<option value="">Display</option>
<option value="Show">Show</option>
<option value="Hide">Hide</option>
</select>
</div>
</div>
<div class="text-center">
<button type="submit" name='add_delivery_zone'>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">
<p>Uploaded Delivery Zones</p>
</div>
<div class='row'>
<?php
$stmt = $con -> prepare('SELECT * FROM delivery_zones');
$stmt -> execute();
$stmt -> store_result();
$stmt -> bind_result($id,$fee,$zone,$locations,$display);
$numrows = $stmt -> num_rows();
if($numrows > 0){
while ($stmt -> fetch()) {
echo"
<div class='col-md-4'>
<form action='";?><?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?><?php echo"' method='post'class='php-email-form1'enctype='multipart/form-data'>
<div class='form-row'>
<label for=''>Fee</label>
<div class='form-group col-md-12'>
<input type='number' name='fee' class='form-control' placeholder='Fee' value='$fee' required />
</div>
<div class='form-group col-md-12'>
<label for=''>Zone</label>
<input type='text' name='zone' class='form-control' placeholder='Zone' value='$zone' required />
</div>
<div class='form-group col-md-12'>
<label for=''>Locations</label>
<textarea name='locations' class='form-control' placeholder='Locations' required>$locations</textarea>
</div>"; ?>
<div class='form-group col-md-12'>
<label for=''>Display</label>
<select name='display' class='form-control' required >
<option value='Show' <?php if($display == "Show"){echo"selected";} ?> >Show</option>
<option value='Hide' <?php if($display == "Hide"){echo"selected";} ?> >Hide</option>
</select>
</div>
<?php echo" </div>
<div class='text-center'>
<button type='submit' name='update$id'>Update</button>
<button type='submit' name='delete$id'>Delete</button>
</div>
</form>
</div>
";
if (isset($_POST["update$id"])) {
$fee = mysqli_real_escape_string($con,$_POST['fee']);
$zone = mysqli_real_escape_string($con,$_POST['zone']);
$locations = mysqli_real_escape_string($con,$_POST['locations']);
$display = mysqli_real_escape_string($con,$_POST['display']);
$stmt = $con -> prepare('UPDATE delivery_zones SET fee = ?,zone = ?,locations=?,display=? WHERE id = ?');
$stmt -> bind_param('ssssi', $fee,$zone,$locations,$display,$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 delivery_zones WHERE id = ?');
$stmt -> bind_param('i', $id);
$stmt -> execute();
//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"); ?>