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/thommytonservices.com/public_html/admin1089/ |
<?php session_start();
$page_name = basename($_SERVER['PHP_SELF']);
include("headerstrict.php"); ?>
<title><?php echo $company_name; ?>, Admin, Recent Projects</title>
<!-- ======= 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>Recent Projects</h2>
<p>Edit the Recent projects on the home page</p>
</div>
<div class='row'>
<?php
$stmt = $con -> prepare('SELECT * FROM recent_projects');
$stmt -> execute();
$stmt -> store_result();
$stmt -> bind_result($id,$rp_heading,$rp_para,$rp_picture,$rp_link);
$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'>
<div class='form-group col-md-12'>
<input type='text' name='rp_heading' class='form-control' placeholder='Heading' value='$rp_heading' required />
</div>
<div class='form-group col-md-12'>
<input type='text' name='rp_para' class='form-control' placeholder='Paragraph' value='$rp_para'required />
</div>
<div class='form-group col-md-12'>
<input type='text' name='rp_link' class='form-control' placeholder='Link' value='$rp_link'required />
</div>
</div>
<div class='form-row'>
<div class='form-group col-md-12'>
<img style='width:100%;border-radius:5px;' src='assets/img/recent_projects/$rp_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>
<button type='submit' name='delete$id'>Delete</button>
</div>
</form>
</div>
";
if (isset($_POST["update$id"])) {
$rp_heading = mysqli_real_escape_string($con,$_POST['rp_heading']);
$rp_para = mysqli_real_escape_string($con,$_POST['rp_para']);
$rp_link = mysqli_real_escape_string($con,$_POST['rp_link']);
if( ($_FILES["fileField"]["type"]=="") == false ){
unlink("assets/img/recent_projects/$rp_picture");
$random_id = substr(md5(rand()), 0, 20);
$extension = pathinfo($_FILES["fileField"]["name"], PATHINFO_EXTENSION);
move_uploaded_file( $_FILES['fileField']['tmp_name'], "assets/img/recent_projects/$random_id.$extension");
$rp_picture ="$random_id.$extension";
}
$stmt = $con -> prepare('UPDATE recent_projects SET rp_heading = ?,rp_para = ?,rp_link=?,rp_picture=? WHERE id = ?');
$stmt -> bind_param('ssssi', $rp_heading, $rp_para,$rp_link,$rp_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 recent_projects WHERE id = ?');
$stmt -> bind_param('i', $id);
$stmt -> execute();
unlink("assets/img/recent_projects/$picture");
//create a session to verify it's coming from here
$_SESSION["action"] = "true";
$message="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"); ?>