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/adesmiley.com/public_html/admin41345/ |
<?php session_start();
$page_name = basename($_SERVER['PHP_SELF']);
include("headerstrict.php"); ?>
<title><?php echo $company_name; ?>, Admin, Testimonials</title>
<?php
if (isset($_POST['add_homepage_picture'])) {
$name = mysqli_real_escape_string($con,$_POST['name']);
$comment = mysqli_real_escape_string($con,$_POST['comment']);
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/testimonials/$random_id.$extension");
$picture ="$random_id.$extension";
$db_id=0;
$stmt = $con -> prepare('INSERT INTO testimonials VALUES (?,?,?,?)');
$stmt -> bind_param('isss', $db_id,$name,$comment,$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>Testimonials</h2>
<p>Add a testimonial</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="name" class="form-control" placeholder="Name" required />
</div>
<div class="form-group col-md-6">
<input type="text" name="comment" class="form-control" placeholder="Comment" 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">
<p>Uploaded Comments</p>
</div>
<div class='row'>
<?php
$stmt = $con -> prepare('SELECT * FROM testimonials');
$stmt -> execute();
$stmt -> store_result();
$stmt -> bind_result($id,$name,$comment,$picture);
$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='name' class='form-control' placeholder='Name' value='$name' required />
</div>
<div class='form-group col-md-12'>
<input type='text' name='comment' class='form-control' placeholder='Comments' value='$comment'required />
</div>
</div>
<div class='form-row'>
<div class='form-group col-md-12'>
<img style='width:100%;border-radius:5px;'src='assets/img/testimonials/$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"])) {
$name = mysqli_real_escape_string($con,$_POST['name']);
$comment = mysqli_real_escape_string($con,$_POST['comment']);
if( ($_FILES["fileField"]["type"]=="") == false ){
unlink("assets/img/testimonials/$picture");
$random_id = substr(md5(rand()), 0, 20);
$extension = pathinfo($_FILES["fileField"]["name"], PATHINFO_EXTENSION);
move_uploaded_file( $_FILES['fileField']['tmp_name'], "assets/img/testimonials/$random_id.$extension");
$picture ="$random_id.$extension";
}
$stmt = $con -> prepare('UPDATE testimonials SET name = ?,comment=?,picture=? WHERE id = ?');
$stmt -> bind_param('sssi', $name,$comment,$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 testimonials WHERE id = ?');
$stmt -> bind_param('i', $id);
$stmt -> execute();
unlink("assets/img/testimonials/$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"); ?>